Project 4

The Projects

For these problems, you are to write a program that reads the necessary information to compute and output the indicated values, as efficiently as possible. Following the pattern in the lab exercise, you should first, design using OCD; then code your design in C++ using stepwise translation; finally, test your program thoroughly.

Project #4.1: Write a menu-driven "police sketch artist" program. The program should use four different menus for: Each menu must provide at least four different choices. Your program should display "sketches" of the person being described, along the lines of those below (hopefully yours will be even better!):
     |     |        .......     \|||||||/
    ---------       .     .      |     |
    (| O O |)      (|-0-0-|)    (| . . |)
     |  _\ |        |  ^  |      |  >  |
     |\___/|        | --- |      |||-|||
      -----          -----        |||||
Organize your program in such a way that it contains no redundant code.

Project #4.2: A year is a leap year if it is evenly divisible by 4, unless it is divisible by 100, in which case it must also be divisible by 400. That is, 1996 was a leap year because it is divisible by 4 and not 100, 1997 was not a leap year because it is not divisible by 4, 2000 was a leap year because it is divisible by 400, but 2100 will not be a leap year because it is divisible by 100 but not 400.

Write a program that inputs a year and displays whether or not it is a leap year.

Project #4.3: A gas company bases its charges on consumption according to the following table:

Gas Used Rate
First 100 meters $5.00 minimum cost
Next 100 meters 5 cents per cubic meter
Next 200 meters 2.5 cents per cubic meter
Above 400 meters 1.5 cents per cubic meter

Meter readings are four-digit numbers that represent cubic meters. Write a program in which the meter reading for the previous month and the current meter reading are entered; the amount of gas used = the difference in the readdings is calculated; and then the amount of the bill is calculated. For example, if the previous month's reading is 1222 and the current month's reading is 1362, then 1362 - 1222 = 140 meters were used. The customer is charged 5 + 40*.05 = 7 dollars. (Note: The current reading may be less than the previous one; for example, one month's reading might be 9876 and the next month's reading 0103. This means that the meter reading "rolled over" to 0 after it reached 9999 so the usage was 10000 - 9876 + 103 = 227 meters.)

Project #4.4: Write a program that will read a sequence of numbers from the keyboard, and display the minimum, maximum, average, and range of the entered values. Make the input step "fool-proof".

Project #4.5: Build a "police sketch artist" program as described in Project #4.1, but write a dynamic program that lets the user experiment with different combinations of facial parts in a single execution. Control the program using a loop. Start with a 'blank' face. Allow the user to modify this face using a two-level hierarchical menu, with the first level allowing the user to select which facial part they want to modify (i.e., a menu of menus), and the second level allowing the user to select from among the choices for that particular facial part.

Back to the Lab Exercise

Back to This Lab's Home Page

Report errors to Larry Nyhoff (