ITEC 120 LAB 11 Back to Lab index page

Student

You will write Java class for a Student.

Student

- name : String
- test1 : int
- test2 : int
- test3 : int
- ave : double

+ Student (String studentname)
+ aveTests ( ) : double
+ setTest ( int num, int score ) : void
+ toString ( ) : String

Write a driver program which asks the user for the student's name and constructs a student with that name. Then, ask the user for 3 test scores, and set the 3 test scores with the setTest method. Call the aveTests method for the student, and print the student out.

A sample run will look like this:

Program outputs: Please enter a student name:
User inputs: Bugs Bunny
Program outputs:

Please enter test score 1 for Bugs Bunny:

User inputs: 87
Program outputs:

Please enter test score 2 for Bugs Bunny:

User inputs: 78
Program outputs:

Please enter test score 3 for Bugs Bunny:

User inputs: 92
Program outputs:

Bugs Bunny
     Test 1: 87
     Test 2: 78

     Test 3: 92
Average of test scores:
85.67


Once you have your program working, show your lab to the Peer Instructor to be checked off.