January 2014
Intermediate to advanced
736 pages
70h 43m
English
Figure C.5 shows the Java class GradeBook containing method determineClassAverage that implements the pseudocode algorithm of Fig. C.4. Although each grade is an integer, the averaging calculation is likely to produce a number with a decimal point—in other words, a real (i.e., floating-point) number. The type int cannot represent such a number, so this class uses type double to do so.
1 // Fig. C.5: GradeBook.java 2 // GradeBook class that solves the class-average problem using 3 // sentinel-controlled repetition. 4 import java.util.Scanner; // program uses class Scanner 5 6 public class GradeBook 7 { 8 private String courseName; ...
Read now
Unlock full access