CS 1401, Quiz 8

Date: Monday, March 10, 2008
Name (please type legibly, ideally in block letters): ______________________________________________________________________
1. Mark what is covered and what is not covered in Chapter 8:

2-4. On March 10, 1876, Alexander Graham Bell made the first successful telephone call. Now, not only phone communications are helped by computers, but the phone bills are generated by computers as well. Let us assume, for simplicity, that the amount to pay is equal to the cost per phone + number of minutes times a cost per minute. For example, if a cost per phone is $10.00, number of minutes was 350, and cost per minute is $0.02, this person must pay $10.00 + 350 * $0.02 = $17.00.

2. Write a method named phoneBill that, given the cost per phone, number of minutes, and cost per minute, returns the overall amount to pay.

3. Call your method phoneBill in the main method to compute the payment for a professor K who is charged $10 per phone, and who spent 350 minutes on the phone at 2 cents ($0.02) per minute. (You do not need to write the entire main method, just the part that assigns the corresponding value to the variable howMuch and calls your method.)

4. Trace, step by step, how the computer will perform the needed computations, and check that the result is indeed correct (should be $17).