0

How to write a simple java program with user input ?

taking the user input and then comparing the input and then printing the output using if statement

10th Jul 2017, 6:18 PM
AKcd
7 Answers
0
your code has x.nextint(); it should look like this x.nextInt(); "i" must be capital letter :)
11th Jul 2017, 8:07 AM
D_Stark
D_Stark - avatar
+ 2
import java.util.*; public class Program { public static void main(String[] args) { int y; Scanner x = new Scanner(System.in); y = x.nextInt(); if(y == 30){System.out.println("Hello World");} else{System.out.println("please enter 30");} /*hope this helps tried to keep it as simple as possible for ya*/
10th Jul 2017, 6:22 PM
D_Stark
D_Stark - avatar
11th Jul 2017, 1:42 AM
AKcd
0
yes theres nothing wrong with your code just capital the "i" for x.nextInt(); and it will run :)
11th Jul 2017, 7:47 AM
D_Stark
D_Stark - avatar
0
which 'i'?
11th Jul 2017, 8:01 AM
AKcd
0
Thanks.
11th Jul 2017, 8:09 AM
AKcd
0
no problem
11th Jul 2017, 8:12 AM
D_Stark
D_Stark - avatar