Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribedimage text in transcribedimage text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2014 Nancy France September 15 19 2014 Proceedings Part 3 Lnai 8726

Authors: Toon Calders ,Floriana Esposito ,Eyke Hullermeier ,Rosa Meo

2014th Edition

3662448440, 978-3662448441

More Books

Students also viewed these Databases questions

Question

3. An initial value (anchoring).

Answered: 1 week ago

Question

3. Is it a topic that your audience will find worthwhile?

Answered: 1 week ago

Question

2. Does the topic meet the criteria specified in the assignment?

Answered: 1 week ago