
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question
Please use C++ for response. I need my code fixed according to YELLOW highlighted errors.
![Write a program that removes all non-alphabetic characters from the given input.
Ex: If the input is:
-Hello, 1 world$ !
the output is:
Helloworld
Your program must define and call the following function that takes a string as a parameter and returns the string without any non-
alphabetic characters.
string RemoveNonAlpha (string userString)
Remove all non-alphabetic characters - functions
1 #include <iostream>
2 #include <string>
3 using namespace std;
4
5 string RemoveNonAlpha(string userstring) {
6 string final_str;
7 for (int i = 0; i < userstring.size(); ++i)
8 {
9 if ((userstring[i] >= 'a' && userstring[i] <= 'z') || (userstring[i] >= 'A' && userstring[i] <= 'Z'))
10 final_str += userstring[i];
11 }
12 return final_str;
13 }
14 int main() {
15 string user_input_string;
16 cout<<"Enter the string: "<<endl;
17 getline (cin, user_input_string);
18 cout<<endl<<"Final string is : "<<endl;
19 cout << Remove NonAlpha(user_input_string) << endl;
20 return 0;
21 }](https://content.bartleby.com/qna-images/question/d20dfe5a-a4c1-4793-9f05-a80ad59a67d4/06862ac2-0dd1-4dea-b3c9-8f70f63f5bd7/ebnln9s_thumbnail.png)
Transcribed Image Text:Write a program that removes all non-alphabetic characters from the given input.
Ex: If the input is:
-Hello, 1 world$ !
the output is:
Helloworld
Your program must define and call the following function that takes a string as a parameter and returns the string without any non-
alphabetic characters.
string RemoveNonAlpha (string userString)
Remove all non-alphabetic characters - functions
1 #include <iostream>
2 #include <string>
3 using namespace std;
4
5 string RemoveNonAlpha(string userstring) {
6 string final_str;
7 for (int i = 0; i < userstring.size(); ++i)
8 {
9 if ((userstring[i] >= 'a' && userstring[i] <= 'z') || (userstring[i] >= 'A' && userstring[i] <= 'Z'))
10 final_str += userstring[i];
11 }
12 return final_str;
13 }
14 int main() {
15 string user_input_string;
16 cout<<"Enter the string: "<<endl;
17 getline (cin, user_input_string);
18 cout<<endl<<"Final string is : "<<endl;
19 cout << Remove NonAlpha(user_input_string) << endl;
20 return 0;
21 }

Transcribed Image Text:1:Compare output
Output differs. See highlights below.
Input -Hello, 1 worlds!
Your output
Expected output
Enter the String:
Final string is :
Helloworld
Helloworld
t
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 3 steps with 1 images

Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Please use C++ and only use header<iostream>. Any others will not be accepted. Hint included from for assignment. Thank you!arrow_forwardWrite a C code. You should use scanf() and use printf to show the values that you have assigned. The structure type must have following information:Name of structure: city_pComponents of structure:Name (name of the city)Population (number of people in the city)In_California (is the city inside California or not)Speed_limit (usual speed limit inside the city)arrow_forwardWithout using any string literal notation, how do you create the C++ statement that manually creates a null-terminated C-style string as an array of characters. Use the string “Sampson” as your example. Which element is stored in the base address of the array?arrow_forward
- This assignment will give you practice on basic C programming. You will implement a few Cprogramsarrow_forwardWrite C++ code to assign an integer unsystematically to all eight dice. The rand(9) will generate a number between 0 and 9. The number 1 must be added to the appraise. The code should roll eight dice and display random numbers between 0 and 9, plus the dice's sum.arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education

Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON

Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education