Your instructor will assign you one of the problems below. To solve your problem, 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, first, design using OCD; then code your design in C++ using stepwise translation; finally, test your program thoroughly.
Project #6.1: There are three possible sources of user error in
Our program uses
- The user could enter an invalid operation (something other than
- The user could enter a non-numeric value for op1 or op2.
- The user could enter
/for operation and
0for op2 (i.e., a divide-by-zero error).
assert()to guard against these errors, but the diagnostic message displayed by
assert()is not particularly informative or user-friendly. Replace each of the calls to
calculate.cppwith a selective-behavior statement that displays a more user-friendly diagnostic message and terminates the program (using
cstdlib) if the user enters erroneous information.
Project #6.2: 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!):
- hairstyle (e.g., bald, crew-cut, curley, wearing a hat)
- eyes (e.g., beady, bug-eyed, glasses, closed)
- nose (e.g., pug, small, medium, large)
- mouth (e.g., puzzled, smiling, bearded, frowning)----- | | ....... \|||||||/ --------- . . | | (| O O |) (|-0-0-|) (| . . |) | _\ | | ^ | | > | |\___/| | --- | |||-||| ----- ----- ||||| |||Organize your program in such a way that it contains no redundant code. For each of the user's choices, write a separate function to process that choice.
Project #6.3: 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.
LeapYear()function that, given a year, returns true if that year is a leap year, and returns false otherwise. Then write a driver program that tests your function.
Project #6.4: Using the
metriclibrary you created for the project of Lab #4, write a menu-driven program that permits the user to select one of the metric conversions in the library.
Turn the following things: