course.wilkes.edu/CS125Labs
Welcome to the site for CS 125 labs!

 

Hands On C++: Project 6

Prev | Next | Lab 6

Objectives

1. Practice designing programs that use loops.
2. Practice choosing the appropriate kind of loop for a problem.

Introduction

Your instructor will assign you one of the following projects, each of which uses loops controlled by conditions.

Projects

6.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".

6.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.

6.3. Write two "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.

6.4. Build a "police sketch artist" program as described in Hands On C++: Project 5, but write a dymanic program that lets the user experiment with different combinations of facial parts in a single execution. (Hint: 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:

  1. all source files you created for this project; and
  2. the output from an execution of your executable program.

Don't forget to clean up your directory when you are all finished...

Prev | Next | Lab 6

 
  Home

Help

Lab 0

Lab 1

Lab 2

Lab 3a

Lab 3b

Lab 4

Lab 5

Lab 6

Lab 7

Lab 8

Lab 9

Lab 10

Lab 11

Lab 12

Lab 13



Membership

Login




Last update: Wednesday, August 23, 2000 at 2:05:52 PM.
visitors to this page.