Java扫描仪需要额外输入

时间:2017-03-13 17:39:11

标签: java switch-statement java.util.scanner

我正在处理Scanner语句,该语句接受dateAdmission的输入,当我在NetBeans中运行时,其中一个输入需要额外的空白输入。当要求用户输入"输入录取日期"时,额外输入发生在变量case "patient": { System.out.println("Enter name: "); String name = in.nextLine(); System.out.println("Enter Address: "); String address = in.nextLine(); System.out.println("Enter date of birth: "); String dob = in.nextLine(); System.out.println("Enter MCP number: "); int mcp = in.nextInt(); in.nextLine(); System.out.println("Enter date of admission: "); String dateAdmission = in.nextLine(); System.out.println(); String hospital = in.nextLine(); System.out.println("Enter name of doctor: "); String doctor = in.nextLine(); System.out.println("Enter room number: "); int roomNum = in.nextInt(); a[i] = new Patient(name, address, dob, mcp, dateAdmission, hospital, doctor, roomNum); break; }

{{1}}

1 个答案:

答案 0 :(得分:2)

您可能忘记提供System.out.println("Enter hospital");

之前
String hospital = in.nextLine(); 

发生了什么事情,它什么都没有打印,并为医院提供了额外的投入?