Description
- Declare a string and assign it an arbitrary starting value of your choosing
- Display the current contents of your string, then displays the following menu. If a function returns a string, it should replace the contents of your string, otherwise display the resulting information and leave the string unchanged. Function headers are provided; they should be used as-is in the manner appropriate.
- string getInput()
- MUST use getline (with cin)
- Due to differences in treatment of the \n character when we hit enter, cin.ignore may have to be used to fix the input buffer
- Reads user input from cin and stores it in the string being used. Contents will set initial state for the string next loop through program.
- MUST use getline (with cin)
- string printBetween(int a, int b, int step = 1)
- Will return a string containing all numbers between a and b, including a and b, counting up
- G. a = 6, b = 3, output = “3456” (don’t use spaces)
- If only two values are provided in the function call, assumes step of 1
- string getInput()
- Order is unassumed, but data is displayed counting up
- string nonalnum_removed(string input)
- Returns the string provided as input with all characters that are neither digits nor alphabetic removed
- Will probably involve function isalnum (slides/internet for references)
- If a string, str, has its length changed, any saved results from str.length() calls will be STALE, meaning they no longer reflect our data
- string alphabet_numberified(string input)
- Returns the string provided as input, except with (only) alphabetic characters converted to their character codes within the string
- “11a11” would become “119711”
- int sumDigits(string digitString)
- Attempts to read each character as a digit, and returns the sum
- Inclusion of non-digit characters should result in a notification (via cout) of the character that could not be summed up
- void saveString(string savedStr)
- Prints the current string’s contents to a file named <your lab filename>.txt
- You can overwrite the previous contents
- Asks the user if they would like to return to step 2, or exit.
- Prints the current string’s contents to a file named <your lab filename>.txt
- Returns the string provided as input, except with (only) alphabetic characters converted to their character codes within the string
- Returns the string provided as input with all characters that are neither digits nor alphabetic removed
Points:
1 – Documentation, readability, format
3 – Proper use of functions
2 – Proper program flow (conditionals, loops, etc)
2 – Filename, Header, and Submission Process
1 – Files
1 – Output testing
Header
//Author: (your name)
//CPSC 121 Lab 4
//<MM/DD/YY> (Current Date)
Filename
<Last Name><First Initial>lab4.cpp, e.x. my assignment would be named MayElab4.cpp




