ITEC 120 LAB 12 | Back to Lab index page |
Student, continued.
You will modify your Student class
to display letter grades. You'll need to add a private method toLetter
and make changes to the toString method to call the toLetter method.
NOTE: You will make NO changes to your driver program, only the class file.
toLetter will return a character - the letter grade of the number
passed to it as a parameter. Make the parameter an int. Make the toLetter
method be private.
The toString method will invoke the toLetter method 3 times so
that a letter grade will be printed beside the each test grade.
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 |
Next, overload the toLetter
method. The second toLetter method will also return a character - the
letter grade of the number passed to it as a parameter. But, the parameter for
this method will be a double. This toLetter method can also be private.
The toString method will invoke this toLetter method so that a
letter grade will be printed beside the final average, like so:
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 |
Once you have your program
working, show your lab to the Peer Instructor to be checked off.