CS 1401, Quiz #10, version a

Date: Tuesday, November 15, 2005
Name (please type legibly, ideally in block letters): ______________________________________________________________________

1. Use the ? construction to assign to the Boolean variable cheap the value "true" is cost is below 25 and "false" if cost is 25 or above.


  cheap = (cost < 25)? true : false;

2. What is printed by the following code fragment? Trace your results, do not just guess.
for (savings = 0, salary = 20; salary > 0; savings += 5, salary -=5)  
  System.out.println(savings + " " + salary); 

Tracing:

savings =  0 then  5 then 10 then 15 then 20

salary  = 20 then 15 then 10 then  5 then  0

What is printed: 

0 20
5 15
10 10
15 5