MIT | MIT-AITI | Ethiopia 2004

Java Lab 5: Object Oriented Gradebook - Part I

  1. In lab 4, we built a procedural gradebook program. In labs 5, 6 and 7, we're going to write a new object-oriented gradebook program. Please look back as your Gradebook class as needed for help in writing your new object-oriented gradebook.
  2. Create a new class called GradebookOO (that's two O's for Object-Oriented). The class should have a single field which is an array of doubles called grades. This class will have no main method. Compile. Why can't you run this class?
  3. Write two constructors for GradebookOO. The first should take no arguments and initialize the grades field to an array of size zero. The second should take an argument that is an array of doubles and assign that array to the field. Compile.
  4. Add a method to GradebookOO named printGrades that takes no arguments and prints out all the grades in the grades field. Compile.
  5. Add a method to GradebookOO named averageGrade that takes no arguments and returns the average grade in the grades field. Compile.
  6. Create a new class called GBProgram. Add a main method to GBProgram which instantiates a Gradebook with an array of grades, prints out all the grades with a call to the printGrades method, and finds the average grade with the averageGrade method. Compile and run.
  7. (Optional) Use EasyReader, as described in Step 3 of the previous lab, in the main method of GBProgram to allow the user to enter in the grades.
  8. (Optional) Print out a menu to the user, as described in Step 4 of the previous lab, that allows the user to select whether they would like to print out all the grades or find the average grade.

Submission: Submit all of your code for this lab.

Hosted by www.Geocities.ws

1