January 2014
Intermediate to advanced
736 pages
70h 43m
English
The averaging calculation performed by method determineClassAverage in response to the method call at line 14 in Fig. C.3 produces an integer result. The program’s output indicates that the sum of the grade values in the sample execution is 846, which, when divided by 10, should yield the floating-point number 84.6. However, the result of the calculation total / 10 (line 61 of Fig. C.2) is the integer 84, because total and 10 are both integers. Dividing two integers results in integer division—any fractional part of the calculation is lost (i.e., truncated).
Read now
Unlock full access