I am trying to input some text using a scanner but I am having an issue where the output for name is skipping and going to the next line. If I try to input name it will skip and go straight to surname. Can anyone please assist
Scanner input = new Scanner(System.in);
if(input.hasNext("1")){
System.out.print("Input your Name: ");
name = input.next();
System.out.print("Input your Surname: ");
surname = input.next();
System.out.print("Input your ID: ");
id = input.nextInt();
System.out.print("Input the training program: ");
trainingProgramme = input.next();
registerApplicant(name, surname, id, trainingProgramme);
System.out.print("Congratulations! You have registered for the " +trainingProgramme+ " Training Programme");
}
The output:
debug:
Welcome to the Codex Registration system:
Please select an option:
1 Register for a training program
2 Check registration details
3 Exit program
1
Input your Name: Input your Surname: Blah
Input your ID: 6787
Input the training program: Java
Congratulations! You have registered for the Java Training ProgrammeWelcome to the Codex Registration system:
Please select an option: