The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
December 2001



This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.



Posted by Joe on December 15, 2001 at 11:20 PM

can anyone help me with either one of this programs on how to like begin it im desperate.........

1. Define a java class called student. Each student has a name, a count of taken exams, and an average grade in those exams. At the beginning of the semester, we start with a count of 0 exams & an average of 0.

The class should have 3 methods, plus of the constructor:
� GetName : To simply return the student�s name
� GetAverage: To return the student�s average grade so far
AddTest: to add a new test score to the student�s record.

2. Write another Java program that reads information for an unknown number of students in a course section. For each student, read the student's name and a series of test grades for that student. Use -1 as a sentinel to end the test grades for an individual student. Using the Student class, print the name and calculate and print the average of the test grades for each student.

Additional requirements:
� You must use a nested loop. You must use a sentinel of -1 to stop the loop for the test grades for each student. You must use a flag for end-of-input to terminate the loop for the group of students (maybe a null String).
� You must use the Student class file to do the averaging, and to provide the student's name and average to be printed.

Use the following test data, which you can reformat:

John Smith 90 85 80 95 -1
Mary Jones 65 70 60 -1
Paul Adler 55 60 -1
Jean Adams 95 88 85 94 -1
Michael Burns (no test grades) -1
100 95 100 90 -1


Sponsored Links

Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us