MIT | MIT-AITI | Ethiopia 2004

Java Lab 3: Gradebook - Part I

  1. Create a new class called Gradebook
  2. Add a main method to Gradebook. In the main method, declare and initialize and array of doubles to store the grades of a student.
  3. Write a loop to print out all the grades in the array. Make sure that your printout is readable with spaces or new lines between each grade.
  4. Write a new loop to find the sum of all the grades in the array.
  5. Divide the sum by the number of grades in the array to find the student's average.
  6. Print a message to the user showing the average grade. If the average grade is 85.4, the output should be Your average grade is 85.4.
  7. Your program should work if there are 4 grades in the array or 400 grades in the array. That is, you should be able to change the number of grades in the initialized array and compile, and it should run without any problems. Try it out. If it does not, figure out how to rewrite your program so that it does work.
  8. (Optional) Add code to print out the letter grade the student earned based on the average grade. An average in the 90's is an A, in the 80's a B, the 70's a C, the 60's a D, and anything lower is an F.

Submission: Submit all of your code for this lab.

Hosted by www.Geocities.ws

1