Directions:
Write C++ programs that use proper style and documentation
The purpose of this assignment is to assess if you can create a program that uses strings.
The file must be called stringProg.cpp
Main Method
1. Declare a string called myString.
2. Use Call-by-reference pass your string to a method called inputData(); (Hint: uses the &)
3. Use Call-by-value and pass your string to a method called outputData(); (Hint: does not use the &)
inputData Method (Receives string)
- Get input using cin >> into the string variable you received into this method. (I will be entering my full name in the format of: Last, First Middle.
- Using the string methods mentioned in this weeks lecture, have your program change the string to: First Middle Initial Last.
- I would like you to break the string you received apart into 3 separate variables: first, last, middle. (Hint: use find() to find the “,” and spaces and use substr() to extract the pieces)
- Use string concatenation to reassemble the string and overwrite the string you received with the new value.
- You must use each of the following string methods (at least once): substr(), length(), find(), insert(), erase().
- Notice the “,” is missing out of the name.
outputData Method (Receives string)
- Output the new string to the screen using cout <<.
- Comments are required, but pseudocode or flowchart are not.
- All Input/Output should be done using the standard C++ library string class.
- Include: system(“PAUSE”); after your output to pause the screen.
Provide documentation throughout the program. Ensure you include ALL files required to make your program compile and run. I would like to see your .cpp file and the .exe file that is inside your debug directory.