Input mismatch exception usually occurs when you provide an input to your scanner instance with a wrong value.
For example, if you ask for an interger using the scanner.nextInt() and provide a string value instead of an integer value. You would get this type of exception. So please do check input.next() and input.nextInt() lines.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…