0

Input help

I'm trying to make the user put his/her age in the code but I want to do it with a scanner code to make it easier. How would I do this?

13th Nov 2016, 2:09 AM
bdubs5050
bdubs5050 - avatar
3 Respuestas
+ 3
Your code is fine, create a variable name age like import java.util.Scanner; class MyClass { public static void main(String[ ] args) { int age; System. out.print("Enter your age\n"); Scanner myVar = new Scanner(System.in); age = myVar.nextInt(); System.out.println(age); } } your age contains user input value. did I understand your question in right way
13th Nov 2016, 2:21 AM
Aditya kumar pandey
Aditya kumar pandey - avatar
+ 1
import java.util.Scanner; class MyClass { public static void main(String[ ] args) { Scanner myVar = new Scanner(System.in); System.out.println(myVar.nextInt()); } }
13th Nov 2016, 2:14 AM
bdubs5050
bdubs5050 - avatar
0
where is your code. Have you tried anything yet
13th Nov 2016, 2:11 AM
Aditya kumar pandey
Aditya kumar pandey - avatar