Hands On C++: Project 7


The Projects

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 #7.1: 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 #7.2: Extend calculate.cpp into a six-function calculator, as follows:
  1. Add a factorial() operation that, given an integer n, computes n! = 1 * 2 * ... * (n-1) * n.
  2. Redesign Power() so that it handles negative exponents.

Project #7.3: Write (at least) two ASCII graphics functions:
  1. PrintStripe(n, ch); that displays n consecutive ch characters. (e.g., PrintStripe(5, 'X'); should display XXXXX.)
  2. PrintAlternating(n, ch1, ch2); that displays n consecutive pairs of the characters ch1ch2. (e.g., PrintAlternating(3, 'X', 'Y'); should display XYXYXY.)

Use these functions to write a program that draws a picture, such as a flag. For example, you might use these functions to draw a crude facsimile of the U.S. flag that looks like this:

* * * * * * XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 * * * * *
* * * * * * XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 * * * * *
* * * * * * XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 * * * * *
* * * * * * XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 * * * * *
* * * * * * XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Try and draw your picture efficiently (i.e., using loops to minimize the number of statements). Feel free to create additional "graphics" functions.

Project #7.4: Build a "police sketch artist" program as described in Project #6.2, 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.

Turn In

Turn the following things:

  1. This grade sheet.
  2. Your OCD.
  3. Your source program.
  4. The output from an execution of your program.


Lab Home Page | Lab Exercise
© 2003 by Prentice Hall. All rights reserved.
Report all errors to Jeremy D. Frens.