사용자가 0-100이 아닌 숫자를 입력하면 유효성 검사를 추가해야 오류 메시지가 표시됩니다. 내 질문은, 난 그냥 하나의 간단한 라인을 입력해야합니까 아니면 항목을 확인하기 위해 각 프롬프트 후 뭔가를 입력해야합니까? (나는 오늘 뇌가 새들과 함께 사라 졌으므로 이것을 지나치게 생각할지도 모릅니다.) 다음은 조정할 필요가있는 블록입니다.Java - 표시 할 오류 메시지
switch(choice)
{
case 1:
System.out.println("Entering Student Details");
System.out.println("------------------------");
System.out.print(" Student name: ");
name = sc.nextLine();
sc.nextLine();
System.out.print(" Student number: ");
stuNum = sc.nextLine();
System.out.print(" class 0 grade: ");
grade = sc.nextInt();
System.out.print(" class 1 grade: ");
grade2 = sc.nextInt();
System.out.print(" class 2 grade: ");
grade3 = sc.nextInt();
System.out.print(" class 3 grade: ");
grade4 = sc.nextInt();
System.out.print(" class 3 grade: ");
grade5 = sc.nextInt();
System.out.print(" class 4 grade: ");
grade6 = sc.nextInt();
}
}while(choice != 0);
System.out.println("Thank you for using the system.");
요구 사항이 명확하지 않은 경우 선생님에게 문의하십시오 ... –
stuNum = sc.nextLine(); 숫자는 int, float 또는 double이어야합니다. –