Hands On C++: Project 9


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 #9.1: Write a program that reads from a file of real numbers, and displays the minimum, maximum, average, and range of the numbers in the file. The user should be able to enter the name of the input file from the keyboard.

Project #9.2: Write a program that reads the contents of a file and creates an exact copy of the file, except that each line is numbered. For example, suppose the input file contains the following text:
'Twas brillig, and the slithy toves
   Did gyre and gimble in the wabe;
All mimsy were the borogoves,
   And the mome raths outgrabe.
                        - Lewis Carroll
Then the output file should appear something like this:
1: 'Twas brillig, and the slithy toves
2:    Did gyre and gimble in the wabe;
3: All mimsy were the borogoves,
4:    And the mome raths outgrabe.
5:                         - Lewis Carroll
The user should be able to enter the names of the input and output files from the keyboard.

Project #9.3: Using the PigLatin() function we wrote in Exercise #4, write a program that reads a file of words and translates each word in that file into Pig Latin. The user should be able enter the names of the input and output files from the keyboard.

Project #9.4: Write a text-analysis program that reads an essay or composition stored in a text file, and determines the number of words, the number of sentences, the average number of words per sentence, the average number of letters per word, and a complexity rating, using:
complexity = 0.5 * averageSentenceLength + 0.5 * averageWordLength
Based on these calculations, your program should assess the writing level of the essay as: The user should be able to enter the name of the input file from the keyboard.

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.