February 2014
Beginner
1248 pages
62h 25m
English
When the loop terminates, line 26 performs the averaging calculation and assigns its result to the variable average. Line 29 uses System.out’s printf method to display the text "Total of all 10 grades is " followed by variable total’s value. Line 30 then uses printf to display the text "Class average is " followed by variable average’s value. When execution reaches line 31, the program terminates.
Notice that this example contains only one class, with method main performing all the work. In this chapter and in Chapter 3, you’ve seen examples consisting of two classes—one containing instance variables and methods that perform tasks using those variables and one containing method ...
Read now
Unlock full access