import java.util.Scanner;
public class Calculator {
public static void main (String []args){
Scanner playerInput = new Scanner(System.in);
int x = playerInput.nextInt();
String type = playerInput.nextLine();
int y = playerInput.nextInt();
while(true){
switch(type){
case "+":
System.out.println(x + y);
System.exit(0);
case "-":
System.out.println(x - y);
System.exit(0);
case "x":
System.out.println(x * y);
System.exit(0);
case "/":
System.out.println(x / y);
System.exit(0);
default:
System.out.println("That is not a valid response, please choose everything again.");
continue;
}
}
}
}
// What I typed in.
Exception in thread "main" java.util.InputMismatchException // What I didn't type in.
at java.util.Scanner.throwFor(Scanner.java:909)
at java.util.Scanner.next(Scanner.java:1530)
at java.util.Scanner.nextInt(Scanner.java:2160)
at java.util.Scanner.nextInt(Scanner.java:2119)
at Calculator.main(Calculator.java:7)
That seems to be a problem with Java code. This is a Forum for Arduino C/C++ code.
The error seems to have been detected in line 7 of your code but it may be in an earlier line. Line 7 looks very like line 5 which does not seem to have caused a problem.
Try commenting out lines to see if you can pinpoint where the problem is.