740
if(totalKids > numberOfKids)
{
numberOfKids = totalKids;
bestSport = column;
}
// bestSport contains the sport in which the most students
// participated
}
4.Given the following declarations:
final intNUM_DEPTS = 100 ;
final intNUM_STORES = 10 ;
final intNUM_MONTHS = 12 ;
a.double[][][] sales;
b.sales = new double[NUM_DEPTS][NUM_STORES][NUM_MONTHS];
c. 0.0 (double)
d.sum = 0.0;
for(intdepts = 0 ; depts < NUM_DEPTS; depts++)
for(intstores = 0 ; stores < NUM_STORES; stores++)
sum = sum + sales[depts][stores][ 0 ];
// sum contains the sum of the sales for January
e.sum = 0.0;
for(intdepts = 0 ; depts < NUM_DEPTS; depts++)
for(intmonths = 0 ; months < NUM_MONTHS; months++)
sum = sum + sales[depts][ 1 ][months];
// sum contains the sum of the sales for store 2
f. sum = 0.0;
for(intstores = 0 ; stores < NUM_STORES; stores++)
for(intmonths = 0 ; months < NUM_MONTHS; months++)
sum = sum + sales[ 32 ][stores][months];
// sum contains the sum of the sales for department 33
Chapter 13 Exam Preparation Exercises
- c. repetition
4.F(4) = 1,F(6) = –1, and F(5) is undefined
6.ifis the control structure used most often in recursion.
9.Run-time stack
T
E
A
M
F
L
Y
Team-Fly®