0

What code would u use if u want the client to type out the code to answer a question?

The code displays "how old r u?"

5th Aug 2019, 4:20 AM
Karna Das
Karna Das - avatar
4 Answers
0
That depends on the language
5th Aug 2019, 4:27 AM
Jake
Jake - avatar
0
Java
5th Aug 2019, 4:28 AM
Karna Das
Karna Das - avatar
0
if you want the user to answer the question, then your best bet would be using Scanner (which is discussed in the Java tutorials) by first importing it and then assigning the users input to a variable. I’ll write it for you but I suggest you complete the java turorial... import java.util.Scanner; //this imports the Scanner class so you can use it public class Program { public static void main(String[] args) { Scanner scan = new Scanner(System.in); //this creates an instance of the Scanner class we imported, which is used to get user input System.out.println("How old are you?"); int age = scan.nextInt(); //this assigns the users input to an Integer variable named age by using the scanner object we instantiated System.out.println("You are " + age + " years old."); //this will output the value of variable age, which was assigned by user } }
5th Aug 2019, 6:22 AM
Jake
Jake - avatar
0
Thank u so much đŸ˜đŸ‘ŒđŸ»
5th Aug 2019, 6:32 AM
Karna Das
Karna Das - avatar