aspose file tools
The moose likes Beginning Java and the fly likes I think I'm stuck!! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide 1Z0-808 this week in the OCAJP forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "I think I Watch "I think I New topic

I think I'm stuck!!

mike statham

Joined: Feb 24, 2012
Posts: 16
Program will not print anything, and only error is
Exception in thread "main" java.util.InputMismatchException
at java.util.Scanner.throwFor(
at java.util.Scanner.nextInt(
at java.util.Scanner.nextInt(
at StudentGrades.getAverage(
at StudentGrades.main(

Matthew Brown

Joined: Apr 06, 2010
Posts: 4499

If you follow the link the forum software has put in for java.util.InputMismatchException, it will take you to the documentation. Which says "Thrown by a Scanner to indicate that the token retrieved does not match the pattern for the expected type, or that the token is out of range for the expected type."

You're getting it thrown on line 37, which is testScore[num] = inFile.nextInt(); This means that the next thing that's being read by the Scanner isn't an integer. So, what is it? It's all to do with what's in your input file. What is it trying to read at this point?
jQuery in Action, 2nd edition
subject: I think I'm stuck!!