我的目标是提示用户输入多个单独的输入,这些输入将以我可以操作的方式存储数据。
例如:
Question:
What is your username?
What is your name?
Input:
Sparkeyy
Nelson
然后,如果它们是数字,我希望能够将它们相加/相乘。这就是我到目前为止所拥有的。(也是第一个问题,很抱歉格式不正确)
import java.util.*;
public class Program{
public static void main(String args[]){
System.out.println("Enter your username: ");
Scanner scanner = new Scanner(System.in);
String username = scanner.nextLine();
System.out.println("Your username is " + username);
}
public static void (name){
System.out.println("Enter your name: ");
Scanner scanner = new Scanner(System.in);
String name = scanner.nextLine();
System.out.println("Your name is " + name);
}
}