Re: Why do I get this error?
Quote:
InputMismatchException
The nextInt() method called on line 18 is reading a non-numeric String. It wants all numeric digits it can convert to an int.
What did you type in?
What order of input does your program expect? numeric vs non-numeric
What did you give it?
Re: Why do I get this error?
Hey thanks for replying :)
I typed in : 3 Smith 70 Jones 30 Mary 100
The order entered should be numberOfStudents name[0] score[0] name[1] score[1] name[2] score[2]
I'm giving it an integer, string, integer, string, integer, string, integer.
Am I not able to do this? I was trying to make it so the String for loop grabs just the names and the Integer for loop grabs the scores, but keep them together, so name[0] = Smith and score[0] = 70
Re: Why do I get this error?
If you want to read all names and then all scores then your input will have to be in the same order as you attempt to read it. Surely that makes sense. How is the computer supposed to read your mind and skip the score entries and only read the name entries?
Re: Why do I get this error?
Quote:
Originally Posted by
Bryan29
Hey thanks for replying :)
I typed in : 3 Smith 70 Jones 30 Mary 100
The order entered should be numberOfStudents name[0] score[0] name[1] score[1] name[2] score[2]
I'm giving it an integer, string, integer, string, integer, string, integer.
Am I not able to do this? I was trying to make it so the String for loop grabs just the names and the Integer for loop grabs the scores, but keep them together, so name[0] = Smith and score[0] = 70
Quote:
Enter Name: ABC (name[0])
Enter Name: DEF (name[1])
...
...
...
Enter Marks: 12 (score[0])
Enter Marks: 75 (score[1])
...
...
ABC=12
DEF=75
What else do you want it to do?