Im using nextLine
to get the student name and nextInt
to get the Student Id, I have researched on this and tried using Integer.parseInt(input.nextLine());
, but no luck. its working fine the first time but when it loops back to add in another student it asks for the student name and id in the same line which gives input mismatch error. Any solution to this without keeping input.nextLine()
before asking for id as this will force the user to press enter twice after inputting the student name in the first loop. Thanks in advance
String input = "no";
do {
System.out.print("Enter Student Name: ");
String na = in.nextLine();
System.out.print("Enter Student ID: ");
int id = Integer.parseInt(in.nextLine());
System.out.print("Enter Excercise grade: ");
double ex = in.nextDouble();
System.out.print("Enter quiz1: ");
double q1 = in.nextDouble();
System.out.print("Enter quiz2: ");
double q2 = in.nextDouble();
System.out.print("Are you done(yes/no): ");
input = in.next();
}while(!"yes".equals(input));