Georgia State University
Department of Computer
Science
CSC 2311 – Spring
2008
Jaman L. Bhola
Assignment #3 - Due
Thursday,
Note: (1) For all assignments, always use comments to explain your program.
(2) No copying allowed. If it is found that students copy from each other, all of these programs will get 0.
(3) You must use the name given to name your program. Should you use a different name, you would lose 10% of what the program is worth.
Program
description:
Write
a C++ program name word.cpp
to read the input from a
file
and output the results to both an output file and the screen. The
input file name must be supplied by the user and the output
file must
be named output.txt.
Requirements:
1.
The
program must test to see
if the files are opened. If not successful upon opening the files, it
must
print the following message and terminate then program.
C:\
The file you entered either do not exist or the name is spelled wrong.
2.
After
opening both input
file and output file successfully, the program will do the following
with the
data that is in the input file.
(a) Count the number of words (A
word could be made up of characters (a – z or A – Z), hyphen,
apostrophe,
digits, quote, question mark, exclamation mark, comma, period,
semi-colon,
colon) , in the file – each word could be separated by a white space, a
semi –
colon, a period, or an exclamation mark.
(b) Count the number of lines in
the file – each line is separated by the new line character – “\n”
(c)
Count
the number of
sentences – each sentence could be separated by a period, an
exclamation mark,
or a question mark.
(d) Count the number of vowels
in the entire file.
(f) Count the number of punctuations.
3.
Output
all of these values
both on the screen and in the output file.
1.
A 3.5 inches floppy disk (IBM compatible)
consisting of
the .cpp and the .exe files. MAKE SURE THAT YOUR DISK IS VIRUS
CLEAN.
2.
A print out of each of the
.cpp
file (source code).
3.
Make sure that your name is written clearly
both on the print out and
the disk.