Question: Use C++ Assignment2b: string class version Write a C++ program that loops and asks the user to enter an alphanumeric phone number and converts it

 Use C++ Assignment2b: string class version Write a C++ program thatloops and asks the user to enter an alphanumeric phone number andconverts it to a numeric one. Examples: 800-Beat-Cal ; 1-800. Got. Milk

Use C++

Assignment2b: string class version Write a C++ program that loops and asks the user to enter an alphanumeric phone number and converts it to a numeric one. Examples: 800-Beat-Cal ; 1-800. Got. Milk ; 898-IMask.up; 1(800)---got Milk Your program will have 3 files: phone1.h, phonel.c, and assignment2a_main.c. Include phone1.h in phone1.c and assignment2a_main.c. Submit your .c and .h files only; no zipped Files. Make use of the i3 functions in ctype.h like: isalnum, isalpha, isdigit, ispunct, isspace, tolower .. Follow the guidelines and solve using this method to learn functions. Means, you need to write the code for each given function. Do not change the int main(void) function. //File phone2.h #pragma once #include #include #include //for true and false #include //https://www.cplusplus.com/reference/cctype/ using namespace std; bool isValid (string & line); char phone_digit(char ch); void toNumeric (string & line); void puncts_10_spaces (string & line); void remove_spaces (string & line); string format_number (string & line); //file phone2.h #include "phone2.h" //definition of isValid //line is a char array string - ending with '\0' //returns true if line has 10 or 11 ainum characters //false otherwise } //definition of phone_digit //if ch not alpha (not a letter) return ch; leave as is //convert ch to lower case //conver a-z, A-Z to a digit //use switch statement char digit = ''; //... return digit; } //definition of toNumeric //line is a char array string - ending with '10' // use the switch statement we did in last lectures // (800) GOT - milk ; (200) GOT.milk, etc // convert letters to digits; leave rest as is. //call phone_digit() for each char in line array } //definition of puncts_to_spaces 1 //line is a char array string - ending with '\0' // convert punctuations to spaces: use ispunct //... } //definition of remove_spaces 1 //line is a char array string - ending with '\0' //remove the spaces and move the digits to the left //and put '\0' after the last char 1 //definition of format_number //assuming the line size is big enough //insert dash or period after 3 and 6 for this format: 415-555-1212 //add a dash if it starts with 1: 1-415-555-1212; 1.415.555.1212 // You can use . or - char separator = ''; // or '.' string st; //use st.push_back(ch) to add a character to st //if line starts with 1, push 1 and then push the separator return st; } //file assignment2a_main.cpp #pragma warning (disable: 4996) //windows only #include #include #include //for true and false #include #include "phone2.h" using namespace std; int main(void) { cout #include #include //for true and false #include //https://www.cplusplus.com/reference/cctype/ using namespace std; bool isValid (string & line); char phone_digit(char ch); void toNumeric (string & line); void puncts_10_spaces (string & line); void remove_spaces (string & line); string format_number (string & line); //file phone2.h #include "phone2.h" //definition of isValid //line is a char array string - ending with '\0' //returns true if line has 10 or 11 ainum characters //false otherwise } //definition of phone_digit //if ch not alpha (not a letter) return ch; leave as is //convert ch to lower case //conver a-z, A-Z to a digit //use switch statement char digit = ''; //... return digit; } //definition of toNumeric //line is a char array string - ending with '10' // use the switch statement we did in last lectures // (800) GOT - milk ; (200) GOT.milk, etc // convert letters to digits; leave rest as is. //call phone_digit() for each char in line array } //definition of puncts_to_spaces 1 //line is a char array string - ending with '\0' // convert punctuations to spaces: use ispunct //... } //definition of remove_spaces 1 //line is a char array string - ending with '\0' //remove the spaces and move the digits to the left //and put '\0' after the last char 1 //definition of format_number //assuming the line size is big enough //insert dash or period after 3 and 6 for this format: 415-555-1212 //add a dash if it starts with 1: 1-415-555-1212; 1.415.555.1212 // You can use . or - char separator = ''; // or '.' string st; //use st.push_back(ch) to add a character to st //if line starts with 1, push 1 and then push the separator return st; } //file assignment2a_main.cpp #pragma warning (disable: 4996) //windows only #include #include #include //for true and false #include #include "phone2.h" using namespace std; int main(void) { cout

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!