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 EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "I think I Watch "I think I New topic
Author

I think I'm stuck!!

mike statham
Greenhorn

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(Scanner.java:909)
at java.util.Scanner.next(Scanner.java:1530)
at java.util.Scanner.nextInt(Scanner.java:2160)
at java.util.Scanner.nextInt(Scanner.java:2119)
at StudentGrades.getAverage(StudentGrades.java:37)
at StudentGrades.main(StudentGrades.java:109)

Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4240
    
    7

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: http://aspose.com/file-tools
 
subject: I think I'm stuck!!
 
Similar Threads
Actually I'm lost
Help setting up an array and other issues
Changing array I think and the print statement
TestScores
TestScores