This code is working for the first scanner to accept ints but the second scanner throws a mismatch error. I cannot seem to find why it is doing this. Can anyone help me out? I have tried everything and it is not working. I can get the first scanner to accept strings multiple times. The second scanner will accept ints but if i try to input a string even one time then the program crashes. How can this be resolved?
For more details of full program click here:
pastebin.com/iMgNncMH
Password: ENdu4mWLNm
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
while(true) {
System.out.println("Enter two integers:");
while (!scanner.hasNextInt()) {
scanner.next();
}
int n1 = scanner.nextInt();
int n2 = scanner.nextInt();
System.out.println();