Win a copy of Design for the Mind this week in the Design forum!

# Actually I'm lost

mike statham
Greenhorn
Posts: 23
Create a java program that accepts student names and test scores from a file and displays their name, average score and letter grade to the screen. Your program will then display summary information as explained below.

For testing, create an input file with at least 4 students with 3 grades per student like the following:

Connie 82 95 79
James 97 99 80
Susan 15 67 75
Jake 72 65 62
Karen 82 72 78

Your program must use a looping structure to read the file, calculate each students average scores then display the students name, their average and letter grade as shown below.

Your program also must count the number of students who earned an A, B, C, D and F. Also, calculate the average grade for the entire class.

You program MUST use a looping structure to read the file and to process each students average score (inner loop).

EXAMPLE Output:

Connie has an average grade of 85.33%. You will receive a B in this class.
James …….
For each student…

Overall Class Average is 78.23%

The following lists the number of students earning each letter grade:

A = 2
B = 1
C = 5
D = 2
F = 1

Error I get is: Exception in thread "main" java.lang.NullPointerException
But I'm sure that there is more

Tim Moores
Bartender
Posts: 2743
37
So which object is null? (Hint: It's an object that you're actually assigning null to. :-)

Rod Singh
Greenhorn
Posts: 16
Modify the line :

as

mike statham
Greenhorn
Posts: 23
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 2

Is what I get after applying the suggestion todo the the following

Marco Galea
Ranch Hand
Posts: 30
mike statham wrote:Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 2

Is what I get after applying the suggestion todo the the following

Hi there first of all in your for loop you should write :

since the array has 20 elements and starts storing elements from 0 to 19

secondly the letterGrade[] you specified that it has 2 elements in line 10 when in reality it should i suppose have 20 aswell since it's using the same variable 'i' !!

Rod Singh
Greenhorn
Posts: 16
• 1

[DELETED]

mike statham
Greenhorn
Posts: 23
Thank you, Rod Singh...But I see I still have alot too learn. Your works!!

I'm looking at yours and mine and letting my brain try to wrap around it.

I don't think your a greenhorn by any means, again thank you and everyone else!

Rod Singh
Greenhorn
Posts: 16
You're welcome!