Hello all,
Once I run the application, the menu is printed and showing available options the user has got to choose from.
If a user chooses option one the function register() should be called and the console should ask for the name, surname, dob and other parameters which will be assigned to the object inside a patient class which will be stored within linked listed called, patientList.
However, for some reason, once the function is launched it prints the line asking to enter the first name of the patient but skips the input for the name and goes forward towards printing the second line asking to enter the surname and stops waiting at the input of surname.
import java.util.LinkedList; import java.util.Scanner; public class Main { private static Scanner input = new Scanner(System.in); private static LinkedList<Patient> patientList = new LinkedList<>(); public static void main(String[] args) { boolean quit = false; int choice; printInstructions(); while (!quit) { System.out.println("Enter your choice: "); choice = input.nextInt(); switch (choice) { case 0: printInstructions(); break; case 1: register(); break; case 2: printPatients(); break; case 9: quit = true; break; default: printInstructions(); break; } } } private static void printInstructions() { System.out.print( "****************************\n" + "\tArmstrong GP Surgery\n" + "****************************\n" + "\n" + "1. \t Register a new patient.\n" + "2. \t Show Patients.\n" + "9. \t Exit the program.\n"); } private static void register() { System.out.println("To register a new patient please his name:"); String name = input.nextLine(); System.out.println("To register a new patient please his surname:"); String surname = input.nextLine(); System.out.println("To register a new patient please his date of birth:"); String dob = input.nextLine(); System.out.println("To register a new patient please his address:"); String address = input.nextLine(); System.out.println("To register a new patient please his post code:"); String post_code = input.nextLine(); System.out.println("To register a new patient please his phone number:"); String phone = input.nextLine(); System.out.println("To register a new patient please his email address:"); String email = input.nextLine(); patientList.add(new Patient(name, surname, dob, address, post_code, phone, email)); } private static void printPatients() { if (patientList.size() == 0) { System.out.println("No patients registered."); } else { for (Patient patient : patientList) { System.out.println(patient.getName()); System.out.println(patient.getSurname()); System.out.println(patient.getUniqueID()); } } } }