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?"
4 Antworten
0
That depends on the language
0
Java
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
}
}
0
Thank u so much 😁👌🏻