Answered step by step
Verified Expert Solution
Question
1 Approved Answer
COMP B12 Assignment #1 C++ INTRODUCTION The purpose of this lab is to give you an opportunity to practice programming in C++ and to familiarize
COMP B12 Assignment #1 C++ INTRODUCTION The purpose of this lab is to give you an opportunity to practice programming in C++ and to familiarize yourself with string I/O and string manipulation. Filter Write a program that repeatedly reads lines until an EOF is encountered. As each line is read, the program strips out all characters that are not upper or lower case letters or spaces, and then outputs the line. Thus, the program acts as a filter and issues no prompt. There are many ways this program could be written, but to receive full credit, you must observe the following Place your code in a file called filterChars.cpp The program should consist of four functions whose prototypes are o int main(); o void removeNonAlpha (string& str); o bool isUpperCaseLetter (char ch); o bool isLowerCaseLetter(char ch); . The mainO function should 1. read string input an entire line, including spaces (try getline0) 2. call removeNonAlpha0 to process the input string 3. print out the string as altered by removeNonAlpha0 4. not call isUpperCaseLetterO or isLowerCaseLetter) directly The function removeNonAlpha0 alters its string reference variable by removing all characters that aren't upper or lower case letters or spaces. Use the function eraseO in the string class to remove the characters. Use the functions isUpperCaseLetterO and isLowerCaseLetterO to help identify which characters to remove The functions isUpperCaseLetter) and isLowerCaseLetterO simply return true if the character parameter is an upper-case or lower-case letter, respectively, and false otherwise. These two functions can easily be one-liners. Note: Don't use any library functions (specifically, use neither islower nor isupper) in isUpperCaseLetter0 and isLowerCaseLetter). Use an if statement or a Boolearn expression instead. Why? For practice. Getting the input to work correctly can be kind of tricky. Try using while(getline(cin, inString)) Shown below is a sample run of the program
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started