Java程序辅导

C C++ Java Python Processing编程在线培训 程序编写 软件开发 视频讲解

客服在线QQ:2653320439 微信:ittutor Email:itutor@qq.com
wx: cjtutor
QQ: 2653320439
Java Lab 5: GradebookOO – Part 1                         Monday, June 21, 2004 
 
Read instructions carefully! Following instructions is part of the grade for this lab.  
 
This lab is due at 5 pm today, at which point solutions will be posted at a location to be 
announced to the class. Make sure you read through the entire lab before attempting any 
of the parts to manage your time appropriately. 
 
In labs 3 and 4, we built a procedural gradebook program. In labs 5, 6 and 7, we are 
going to write a new object-oriented gradebook program. Please look back at your 
Gradebook class as needed for help in writing your new object-oriented gradebook. 
 
0. Create a new folder named lab5 in the folder C:\java\lastName (where lastName is the 
variable that stores your last name). This is the folder to which you will be saving all the 
files required for this lab. 
 
1.(2 points) 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? 
 
2. (2 points) Write two constructors for GradebookOO. This first should take no 
arguments and initialize the grades field to an array of zero.  The second should take an 
argument that is an array of doubles and assign that array to the field. Compile. 
 
3. (2 points)Add a method to GradebookOO named printGrades that takes no 
arguments and prints out all the grades in the grades field. Compile. 
 
4. (1 point) Add a method to GradebookOO named averageGrade that takes no 
arguments and returns the average grade in the grades field. Compile. 
 
5. (3 points) Create a new class called GBProgram. Add a main method to GBProgram 
which instantiates a GradebookOO 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. You should also print out the average grade. Compile and run. 
 
All students are required to check off the required part of the lab before proceeding 
to the optional part. 
 
6. (Optional – 2 points) Use EasyReader, as described in Step 3 of lab 4, in the main 
method of GBProgram to allow the user to enter in the grades from the command line. 
Remember to copy the file EasyReader.class into your lab5 folder in order for this to 
work. 
 
7. (Optional – 2 points) Print out a menu to the user, as described in Step 4 of lab 4, that 
allows the user to select whether they would like to print out all the grades or find the 
average grade. 
 
8. CheckOff 
Please ensure that you have the files GradeBookOO.java and GBProgram.java in the 
folder named lab5 that you created in step 0.  
 
If you are ready to be checked off before 5pm, call one of the team members who will 
assign you a grade for the lab. Otherwise, you may leave the required files on your 
machine for us to evaluate at our own convenience.  
 
We will not accept modifications to the required files after the lab is officially due.