CS 1401, Quiz #10

Date: Tuesday, April 18, 2006
Class section (9 am or 10:30 am): ____________________________
Name (please type legibly, ideally in block letters): ______________________________________________________________________

1. Use the ? construction to assign to the Boolean variable warm the value "true" is temperature is above 80 and "false" if temperature is 80 or below.


  warm = (temperature > 80)? true : false;

2. What is printed by the following code fragment? Trace your results, do not just guess.
for (day = 15, temperature = 80; day <= 19; day++, temperature +=5)
  System.out.println(day + " " + temperature);

Tracing:

day =  15 then 16 then 17 then 18 then 19

temperature = 80 then 85 then 90 then 95 then 100

What is printed:

15 80
16 85
17 90
18 95
19 100