We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Java Stdin and Stdout II
Java Stdin and Stdout II
+ 0 comments This is the correct code
public class Solution {
public static void main(String[] args) { Scanner scan = new Scanner(System.in); int i = scan.nextInt(); scan.nextLine(); double d = scan.nextDouble(); scan.nextLine(); String s = scan.nextLine(); scan.close(); // Write your code here. System.out.println("String: " + s); System.out.println("Double: " + d); System.out.println("Int: " + i); }
}
+ 1 comment import java.util.Scanner;
public class Solution {
public static void main(String[] args) { Scanner scan = new Scanner(System.in); int i = scan.nextInt(); double d = scan.nextDouble(); String sw = scan.next(); String s = scan.nextLine(); // Write your code here. System.out.println("String: " + sw + s); System.out.println("Double: " + d); System.out.println("Int: " + i); }
}
+ 1 comment import java.util.Scanner;
public class Solution {
public static void main(String[] args) { Scanner scan = new Scanner(System.in); int i = scan.nextInt(); double d = scan.nextDouble(); scan.nextLine(); String s = scan.nextLine(); System.out.println("String: " + s); System.out.println("Double: " + d); System.out.println("Int: " + i); }
}
+ 2 comments here's my solution, its failing in test case 1 and 2 kindly help me understand how can i make it generic public class Solution {
public static void main(String[] args) { Scanner scan = new Scanner(System.in); int i = scan.nextInt(); double d=scan.nextDouble(); String s= ""; // Write your code here. while(scan.hasNext()) { s += scan.next(); s += " "; } scan.close(); System.out.println("String: "+s); System.out.println("Double: " + d); System.out.println("Int: " + i); }
}
+ 0 comments import java.util.Scanner;
public class Solution {
public static void main(String[] args) { Scanner scan = new Scanner(System.in); int i = scan.nextInt(); double d=scan.nextDouble(); String sw = scan.nextLine(); String s =scan.nextLine(); if(s!=null){ sw=sw+s; } System.out.println("String: "+sw); System.out.println("Double: " + d); System.out.println("Int: " + i); }
}
Load more conversations
Sort 1102 Discussions, By:
Please Login in order to post a comment