This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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 Android Security Essentials Live Lessons this week in the Android 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: 4343

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?
I agree. Here's the link:
subject: I think I'm stuck!!
Similar Threads
Changing array I think and the print statement
Actually I'm lost
Help setting up an array and other issues