This website is preserved for historical and scholarly reference and is no longer actively maintained.

QUIZ 7

September 9, 1998



#1. What does the text say about the following four Java statements? If any are the same, explain how they are the same. If any differ, explain how they differ.

a) x = x + 1;
b) x += 1;
c) x++;
d) ++x;

#2. Workers working more than 40 hours receive overtime pay consisting of 1.5 times their normal rate of pay for the hours worked over 40. Those working less than or equal to 40 hours receive the number of hours worked times the rate of pay. Given the declarations below, write a conditional statemenet to compute the total pay for the week.

int hours; // hours worked
int rate; // rate of pay
int totalPay; // total pay for the week


#3. Rewrite the following as a cascaded if/else statement:

switch ( x ) {
case value1: statement1; break;
case value2: statement2; break;
case value3: statement3; break;
default: statement4; break;
}



Return to Eleanor Hare's home page.

Return to Department of Computer Science Home page.