Project 7


The Projects

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 #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 (nyhl@cs.calvin.edu)