Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (13.1k points)

Can anyone help me with the below error, when I was trying to input the double value in throws this error:

Exception in thread "main" java.util.InputMismatchException

at java.util.Scanner.throwFor(Scanner.java:909)

at java.util.Scanner.next(Scanner.java:1530)

at java.util.Scanner.nextDouble(Scanner.java:2456)

at MarkingSystem.checkValueWithin(MarkingSystem.java:25)

at MarkingSystem.askForMarks(MarkingSystem.java:44)

at World.main(World.java:6)

Java Result: 1

Any help would be appreciated.

1 Answer

0 votes
by (26.7k points)

So basically, this error popped up if the token is not a float or is out of range. You can try to catch the following exception like:

try {

    // ...

} catch (InputMismatchException e) {

    System.out.print(e.getMessage()); //try to find out specific reason.

}

I hope this will help.

Want to know more about Java? Prefer this tutorial on Learn Java.

Want to become a Java Expert? Join Java Course now!!

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...