Java Reference
In-Depth Information
Display 6.20
Demonstration of the Class GradeBook
1 public class GradeBookDemo
2 {
3 public static void main(String[] args)
4 {
5 GradeBook book = new GradeBook();
6 book.display();
7 }
8 }
Sample Dialogue
Enter number of students:
4
Enter number of quizzes:
3
Enter score for student number 1
on quiz number 1
10
Enter score for student number 1
on quiz number 2
10
<The rest of the input dialog is omitted to save space.>
Student 1 Quizzes: 10 10 10 Ave = 10.0
Student 2 Quizzes: 2 0 1 Ave = 1.0
Student 3 Quizzes: 8 6 9 Ave = 7.66666666667
Student 4 Quizzes: 8 4 10 Ave = 7.33333333333
Quiz averages:
Quiz 1 Ave = 7.0 Quiz 2 Ave = 5.0 Quiz 3 Ave = 7.5
Self-Test Exercises
24. Write a method defi nition for a method with the following heading. The
method is to be added to the class GradeBook in Display 6.18 .
/**
Returns the grade that student numbered studentNumber received
on quiz number quizNumber.
*/
public int getGrade( int studentNumber, int quizNumber)
(continued)
 
 
Search WWH ::




Custom Search