Java Reference
In-Depth Information
9
// array of student grades
int [] gradesArray = { 87 , 68 , 94 , 100 , 83 , 78 , 85 , 91 , 76 , 87 };
10
11
12
GradeBook myGradeBook = new GradeBook(
13
gradesArray
"CS101 Introduction to Java Programming" ,
);
14
System.out.printf( "Welcome to the grade book for%n%s%n%n" ,
15
myGradeBook.getCourseName());
16
myGradeBook.processGrades();
17
}
18
} // end class GradeBookTest
Welcome to the grade book for
CS101 Introduction to Java Programming
The grades are:
Student 1: 87
Student 2: 68
Student 3: 94
Student 4: 100
Student 5: 83
Student 6: 78
Student 7: 85
Student 8: 91
Student 9: 76
Student 10: 87
Class average is 84.90
Lowest grade is 68
Highest grade is 100
Grade distribution:
00-09:
10-19:
20-29:
30-39:
40-49:
50-59:
60-69: *
70-79: **
80-89: ****
90-99: **
100: *
Fig. 7.15 | GradeBookTest creates a GradeBook object using an array of grades, then invokes
method processGrades to analyze them. (Part 2 of 2.)
Java SE 8
In Chapter 17, Java SE 8 Lambdas and Streams, the example of Fig. 17.5 uses stream
methods min , max , count and average to process the elements of an int array elegantly
and concisely without having to write repetition statements. In Chapter 23, Concurrency,
the example of Fig. 23.29 uses stream method summaryStatistics to perform all of these
operations in one method call.
 
Search WWH ::




Custom Search