February 2014
Beginner
1248 pages
62h 25m
English
In Fig. 4.10, method main (lines 7–46) implements the pseudocode algorithm of Fig. 4.9. Although each grade is an integer, the averaging calculation is likely to produce a number with a decimal point—in other words, a real (floating-point) number. The type int cannot represent such a number, so this class uses type double to do so. You’ll also see that control statements may be stacked on top of one another (in sequence). The while statement (lines 22–30) is followed in sequence by an if...else statement (lines 34–45). Much of the code in this program is identical to that in Fig. 4.8, so we concentrate on the new concepts.
Read now
Unlock full access