I'm working on this code which takes an integer as a test case then takes a string and an integer for each test case But I keep getting this exception:
Exception in thread "main" java.util.InputMismatchException
at java.util.Scanner.throwFor(Unknown Source)
at java.util.Scanner.next(Unknown Source)
at java.util.Scanner.nextInt(Unknown Source)
at java.util.Scanner.nextInt(Unknown Source)
at OverSizedPancakeFlipper.main(OverSizedPancakeFlipper.java:18)
My code basically looks like this:
Scanner userInput = new Scanner(System.in);
int T=userInput.nextInt();
userInput.nextLine();
while(T-->0){
String S=userInput.nextLine();
char[] ch = S.toCharArray();
int K=userInput.nextInt();
//code does work here
}
Do let me know if you need any other information and thanks for all the help.