Programming
Assignment #5, 6
CS
161: Introduction to Computer Science 1
Unlike
the previous programs, this program contains two parts to cover the concepts
that normally would have been split between two programs.
**This
is your last programming project this term! **
Program Assignment:
The goal of this program is to
experience working with arrays of characters and working with external data
files. You may not use the string class
in this assignment. Instead, you MUST use arrays of characters! And, yes,
you can use the cstring library.
You have started working on some papers
for your other classes. In the back of your mind you have wondered if a program
could help you more (or less!) than the normal word processors that you are
using. Some of your teachers are very precise about how many words you can
write, how many times you use run on sentences (with but, and, or semicolons),
etc. So, you have decided to write a program to keep you on track.
Phase 1) Arrays of characters
· Read in a paragraph (or more) from the user (hint: read one word at a time)
· As you read, count the number of times they use “but”, “and”
· Count the number of times words end in ‘;’
· Count the number of words.
· Do not echo the paragraph!
· Stop reading when the user has entered a # sign as the first
character on a line
· Output the results to the user
Phase 2) External Data Files
· Once you are comfortable with Phase 1, add the ability to
write the paragraph to an external data file
· The filename should be read in from the user
(prompt/read/echo/confirm)
· Near the end of the program, Phase 2 should add the ability
to read the text back into the program. This time you are interested in
counting the number of sentences (ending in period only). (hint: read using the
3 argument version of cin.get)
· Output the paper back to the user as you read. Make sure as
you do this to capitalize the first letter of each sentence.
Important
things to keep in mind
1.
Write at
least three functions with arguments for this assignment.
2.
Allow the
user to enter in the name of the external data file.
3. Watch out. When using the 3 argument version of cin.get you
need to make sure to remove all delimiter
(.) from the input buffer.
4. You should use the cstring library strcmp, strcpy, and strlen functions.
5. The program should experiment with BOTH cin >> array as well as cin.get( 3 argument);
On
the due date, turn in:
a. Remember to email your program to karlafgr@cs.pdx.edu
b. Remember to turn in an algorithm with your program – it
should be in your header comments! It is worth 20% of your program grade. And,
don’t forget to add comments and to work on your program’s readability; this is
another 20%!!