Back to DFS's C Page
OAC Problem Set IV
Using a Switch
Due: Before your test on 12 Nov 99
This is the classic Chinese menu problem. Include all of the following features in a single program.
- You must produce a labeled menu for the Hong Kong Restaurant which includes the following item numbers, items and prices. Your menu must be aligned as in the table below, but should not include the borders. You are not permitted to use more than a single wordspace to separate any two elements in a row -- you must use string constants with the positioning on the line done using appropriate use of the format control string in the printf() calls.
| Hong Kong Restaurant |
| 2. | Delicious Egg Roll | $1.00 |
| 3. | Mandarin Egg Roll | $1.35 |
| 4. | Ja-Doo Chicken Wings | $5.95 |
| 5. | Peel 'N Eat Shrimp | $10.95 |
| 30. | Steamed Rice | $1.25 |
| 31. | Plain Fried Rice | $3.25 |
| 106. | Beef with Snow Peas & Baby Corn | $8.95 |
| 108. | Beef with Chinese Greens | $7.95 |
| 120. | Chicken with Almonds and Mixed Vegetables | $7.25 |
| 121. | Chicken with Broccoli | $8.25 |
| 155. | Snap 'N Eat Crab Legs | $15.95 |
| 159. | Tai Dop Voy | $9.95 |
| 221. | French Fries | $1.95 |
| 222. | Onion Rings | $3.95 |
- Your program must use a switch (see the sample program) and loop until the waitress enters a zero.
- The screen should be cleared and the menu rewritten each time a selection is entered.
- Instructions to the waitress and a running subtotal are to be printed below the menu.
- Your program must calculate and print (after clearing the screen) the subtotal, the GST, PST, and the grand total in a properly aligned column with labels to the left before exiting.
- This problem is to be done by pairs of students.
To save you the effort of repeatedly typing in the same data while testing your program, follow these instructions:
- Create a test input file called menudata which contains the following data:
2
30
30
108
159
0
- After you have compiled your program called OurLastNamesMenu.c (where OurLastNames is replaced with your names), type the appropriate modification of the following on the command line.
OurLastNamesMenu < menudata
This will cause the program to get its input from the file instead of from the keyboard. Guess how I am going to test your program!
Copies of your source file and executable are to be copied onto my disk. You are also to hand in hardcopy of your source file.
Created 9 Nov 1999
© 1999 DFStermole