-1
以下是Java程序的預期輸出。水平獲取鍵盤輸入?
Hello. What is your name?
Hi John! How old are you?
So you're 22 eh? That's not old at all!
How much do you make John?
500.0! I hope that's per hour and not per year! LOL!
預期輸入: John 22 500
(我需要水平地得到輸入,而不是垂直地)。
那麼我需要做些什麼改變?像任何功能scanner.next()
而不是nextLine()
shoudl被使用或如何?
你能告訴我的程序有什麼問題嗎?
public class Test2 {
public static void main(String args[]) {
Scanner scanner = new Scanner(System.in);
Scanner in = new Scanner(System.in);
Scanner inc = new Scanner(System.in);
String xyz = scanner.nextLine();
int age = in.nextInt();
double cme = inc.nextInt();
System.out.println("Hello.What is your name?");
System.out.println("So you're "+age+"eh?That's not old at all!");
System.out.println("hi"+xyz+"!How old are you?");
System.out.println("How much do you make"+xyz+"?");
System.out.println(+cme+"!I hope that's per hour and not per year!LOL!");
}
}