$29.99
CS162 Spring 2020 Program #2
Individual Programming Assignment #2
CS 162: Introduction to Computer Science
Submit your assignment to the D2L Dropbox
The purpose of the second program is to continue refining our programming
skills in C++ and practice using arrays of characters, the subscript operator, the
cstring library, and functions with arguments. Our goal is to create programs
with a small functions where main delegates to a series of functions where the
real work takes place. In this programming assignment, you are not allowed to
use global variables. Avoid using break (unless working with a switch statement).
Limit your functions to no more than 30 statements of code (not including
comments, blank lines, or variable definitions). Never use a “return” in the
middle of a loop!
The idea with this assignment is to write your own functions to solve this problem.
Program Assignment:
We hope this term is going well for you. We are getting used to doing so much of
our work remotely. I know for myself I am getting a lot of practice typing.
Working from home to this degree is certainly a new experience. There are great
things about it, and sometimes it is hard to focus!
I am finding it is useful to journal my thoughts: ideas of what I want to do, how
I can improve, and ideas for staying focused.
With your second program, we will create a program that will let the user enter
in some text three different categories (ideas, improvements, focus). You are
allowed to pick your own categories. For each category, all the user to enter in a
sentence or even a paragraph of their thoughts. Each should be limited to no
more than 300 characters.
Then, you will want to perform the following on these ideas:
1. Make sure the first character is capitalized
2. Make sure the first character after each period is capitalized
3. Inform the user if two or more categories contain the exact same information
(use strcmp)
4. Ask the user for a word they would like to search for, and let them know
which category it is located in (for example, I want to find out which category
has the word “exercise”). Create your own function that uses a LOOP!
CS162 Spring 2020 Program #2
After performing these items, display the three categories and ask the user if they
would like to do this again! Continue until the user wants to quit.
*** THE ALGORITHM IS CRITICAL! Think about and plan for each of these
events BEFORE you start to program:
1. How to step through the array to look for periods?
2. How do find the next character after a period is located?
3. What would the algorithm be to find a word in an array?
Things you should know...as part of your program:
1. It is expected that you will read into an array of characters! Learning how to
process arrays is one of the major goals of this assignment.
2. You should read using the 3 argument version of cin.get for each. This means
that you will need to perform cin.ignore after each and every input operation.
Pay close attention to doing this. Make no exceptions.
3. Make sure to prompt the user for any input requested. Make sure it is clear from
your prompts what the user is expected to do.
4. Use the cstring library with strlen to know when to stop processing the array of
characters. strlen should not be in the conditional expression. Consider using it
prior to a loop and storing the results of strlen in a variable!!
5. You may not use any global variables in this program!
6. You may not use the string class – instead use arrays of characters with cstrings
7. Make sure to use C++’s I/O (iostream library) for your input and output.
8. FUNCTIONS must be written for this assignment
9. Submit an electronic copy of your .cpp file as an attached file to the dropbox on
D2L (go to: http://d2l.pdx.edu/ to login). Make sure to hit the submit button
after uploading your files (otherwise they will be lost)