CIS-213 ... USING THE C++ LANGUAGE

advertisement
CIS-213
INTRODUCTION TO PROGRAMMING LOGIC II
USING THE C++ LANGUAGE
2006
*******************************************************
*
*
*
The fifth project will be due on
*
*
*
*
Have your materials ready in a folder on the due date
*
*
*
*******************************************************
New concepts in program # 5 include string data manipulation using several of the standard library
string functions available in the header files <string.h> and <ctype.h. We will use the getline ( )
function to input data from our file.
After you have successfully compiled and executed your program, you need to hand in the following
materials in your folder:
(1) a listing of your source code
(2) the results of your program
PROGRAM SPECIFICATIONS FOR PROGRAM # 5
INPUT:
The name of the input file is: STRGDATA.TXT
Refer to the handout for the actual contents of the input file.
FORMULAS (ALGORITHMS):
1. The five (5) totals are simply an accumulation of all the vowels, consonants, spaces, lines and
punctuation marks for each and every character in each and every non_duplicate line.
CONSTRAINTS:
When you attempt to open your file, if there is a problem, simply display the message “Problem
opening the input file” and exit the program.
CIS-213/Program # 5/Page 2
OUTPUT:
Listed below is a sample of what your output may look like after you execute (run) your program.
Actual Text of the File entitled - STRGDATA.TXT
(Without Duplicate Lines of Code)
There several built-in C++ functions that can
be used to test for any number of characteristics
of your input data.
You can test to see if your character data is
alphabetic,
digital, uppercase, lowercase, a space,
a punctuation mark and much much more.
You must pass a character variable
or a constant argument to the function by
placing the argument in the function parentheses
when you call it.
These functions all return a
true or false result,
so you can test their return values inside an
if statement
or a while loop.
TOTALS FOR THE TEXT FILE ENTITLED STRGDATA.TXT
SUMMARY REPORT PREPARED BY: PUT YOUR NAME HERE
DATE:
2006
The total number of vowels is:
The total number of consonants is:
The total number of spaces is:
The total number of lines is:
The total number of punctuation marks is:
nnn
nnn
nnn
nnn
nnn
CIS-112/Program # 5 Page 3
PSEUDOCODE - FUNCTION REPORT ( ) :
Begin
Open input file
Print headers above the listing of the file entitled strgdata.txt (see sample output)
While ( !indata.eof ( ) )
{
indata.getline (data_in [ index ] , 80, ‘\n’ );
index++;
}
Print first line of the array
For (row=0; row < index; row++)
Begin
If (array-item [row] not equal array_item [row +1]
Begin
Print [ row + 1 ]
Add 1 to total lines
For ( col = 0; col < 79; col++)
Begin
if a vowel
- add 1 to total vowels
if a consonant
- add 1 to total consonants
if a space
- add 1 to total spaces
if a punctuation mark - add 1 to total punctuation marks
End of inside for loop
End of if statement
End of outside for loop
Print totals (including headers - see sample output )
End of main ( )
Download