- 1

Output

Why in the in the second time it’s just let me input the address number and n I know because nextInt() but how I can solve it?? do { String name; System.out.print("Enter your name? "); name=input.nextLine(); String address; System.out.print("Enter your Address? "); address=input.nextLine(); int number; System.out.print("Enter your number phone? "); number=input.nextInt(); System.out.println("The information; "); System.out.println(" your name? "+name); System.out.println(" your address? "+address); System.out.println(" your number phone? "+number); System.out.println("if you want to enter again the information, enter y "); again=input.next().charAt(0); } while (Character.toUpperCase(again)=='Y');

10th Apr 2020, 5:32 PM
Reema
1 Answer
0
Reema , the Scanner.next method does not read the newline character created by hitting "Enter," so you might put input.nextLine() after again =input.next().charAt(0); input.nextLine(); to 'consume' the rest of the line and the newline character. else, it will be 'consumed' by your name=input.nextLine(); (which will be skipped)
10th Apr 2020, 5:57 PM
John Robotane
John Robotane - avatar