Skip to content
Advertisement

Exception in thread “main” java.util.InputMismatchException error

I believe I wrote all my code correctly but Im getting this error, can someone help me understand:

JavaScript

Here is my code:

JavaScript

Advertisement

Answer

Your code looks OK.

An InputMismatchException occurs in a Scanner when a given input doesn’t match the expected input format. Your exception occurs on line 15, where a scanner expects a decimal number such as 3.14 (which, depending on your system’s locale, the decimal can be represented by a dot . or a comma ,!)

If you’re certain that the input you’re providing is absolutely a decimal number, but you’re not sure what locale you’re using, you can force a particular locale by using the useLocale method.

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement