programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
• Campbell Ritchie
• Jeanne Boyarsky
• Ron McLeod
• Paul Clapham
• Liutauras Vilda
Sheriffs:
• paul wheaton
• Rob Spoor
• Devaka Cooray
Saloon Keepers:
• Stephan van Hulst
• Tim Holloway
• Carey Brown
• Frits Walraven
• Tim Moores
Bartenders:
• Mikalai Zaikin

# Actually I'm lost

Greenhorn
Posts: 23
• Number of slices to send:
Optional 'thank-you' note:
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

Saloon Keeper
Posts: 7576
176
• Number of slices to send:
Optional 'thank-you' note:
So which object is null? (Hint: It's an object that you're actually assigning null to. :-)

Greenhorn
Posts: 16
• Number of slices to send:
Optional 'thank-you' note:
Modify the line :

as

mike statham
Greenhorn
Posts: 23
• Number of slices to send:
Optional 'thank-you' note:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 2

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

Ranch Hand
Posts: 30
• Number of slices to send:
Optional 'thank-you' note:

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
• Number of slices to send:
Optional 'thank-you' note:

[DELETED]

mike statham
Greenhorn
Posts: 23
• Number of slices to send:
Optional 'thank-you' note:
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
• Number of slices to send:
Optional 'thank-you' note:
You're welcome!