| |||
Problem 01 | |||
For the following sub-problems, start with a program that solves the first problem, then expand it to solve each successive problem. Make the program working for one problem before going on to the next.
| |||
Problem 02 | |||
Ask the user for their annual income. Tell them they are poor, comfortable, or stinking
rich depending on whether their income is less than $20,000, between $20,000 and $50,000,
or greater than $50,000.
| |||
Problem 03 | |||
Write a program which asks the user to type a number from 1 to 5 and
responds with the cardinal version of the number
(i.e. 1st, 2nd, 3rd, 4th, 5th) by printing the number they entered and then
using an if-else-if statement to print the appropriate suffix.Notice that the last two cases use the same suffix. Try to capture that commonality in your program by not having separate cases for those two numbers. Print "out of range" if they enter any value other than 1 through 5.
| |||
Problem 04 | |||
Write another program that does the same thing as the last one, but which uses a switch statement instead of an if statement.
| |||
Last modified August 28 for Fall 99 cs5 by fleck@cs.hmc.edu
This page copyright ©1998 by Joshua S. Hodas. It was built with Frontier on a Macintosh . Last rebuilt on Sun, Sep 27, 1998 at 2:14:01 PM. | |
http://www.cs.hmc.edu/~hodas/courses/cs5/week_04/labsolutions.html | |