0

I'm trying to get the user to enter two strings and store them in two variables called studentName and studentNum, but when I run the program, the first string input is skipped over and only the second string input is allowed to be entered. It prints out normally, but won't allow me to enter a value for studentName. could anyone help me with this problem?

System.out.print("Please enter your name: "); studentName = in.nextLine(); System.out.print("\nPlease enter your student number: "); studentNum = in.nextLine();

1 Answers1

0

Has to do with where the scanner starts and where it puts up a newline character

You can fix this if you change System.out.print to System.out.println

ControlAltDel
  • 28,815
  • 6
  • 42
  • 68