import java.util.Scanner;
public class Solution {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int i = scan.nextInt();
String s = scan.nextLine();
double d = scan.nextDouble();
System.out.println("String: " + s);
System.out.println("Double: " + d);
System.out.println("Int: " + i);
}
}
Asked
Active
Viewed 560 times
-2

Andrew Brēza
- 7,705
- 3
- 34
- 40
-
It runs for me. – BlackHatSamurai Apr 21 '17 at 04:53
-
1Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a [mcve] – GhostCat Apr 21 '17 at 04:54
-
but in my case, when i click run nothing happens – Arafat Hossain Adi Apr 21 '17 at 04:54
-
1When you click "run" something happens. You just don't have any user prompts so it looks like it's not running. I put your code in my IDE and it works. – BlackHatSamurai Apr 21 '17 at 04:55
-
thanks to everyone :) – Arafat Hossain Adi Apr 21 '17 at 05:08
-
Can you clarify the problem? – EJoshuaS - Stand with Ukraine Apr 21 '17 at 05:08
-
In eclipse, when click run as java application nothing happens @ EJoshuaS – Arafat Hossain Adi Apr 21 '17 at 05:15
1 Answers
1
Your code runs, but you should add some user prompts:
import java.util.Scanner;
public class TimeTest {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.println("Input integer:");
int i = scan.nextInt();
System.out.println("Input string:");
String s = scan.nextLine();
System.out.println("Input double:");
double d = scan.nextDouble();
System.out.println("String: " + s);
System.out.println("Double: " + d);
System.out.println("Int: " + i);
}
}
It should be noted that you will have an issue trying to get your string input. You'll want to clear your input by adding another String s = scan.nextLine();
after your String s = scan.nextInt();

BlackHatSamurai
- 23,275
- 22
- 95
- 156