Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need help completing this set of problems.the Language is C++. I have the firs

ID: 3841370 • Letter: I

Question

I need help completing this set of problems.the Language is C++. I have the first condition down, but question two I cannot complete: 1.Prompt the user for a phone number that's in the following format: (AAA) BBB-CCCC AAA is the area code, BBB is the exchange, CCCC is the subscriber number; all of which must be digits and must be the length show here. If the phone number is in the correct format, display the phone number in a new format: AAA.BBB.CCCC and question 2:Prompt the user for a list of phone numbers separated by commas. Use the validation rules from the last question.

I include the first question only for the validation rules, my main issue is with question two. Please and thank you... here are the test cases.

TEST CASES: (307) 736-5739,(174) 558-3171,(572) 770-1891,(411) 496-9352,(865) 999-0212,(178) 165-8712

Enter a list of phone numbers separated by commas (307) 736-5739 -> 307.736.5739 (174) 558-3171 -> 174.558.3171 (572) 770-1891 -> 572.770.1891 (411) 496-9352 -> 411.496.9352 (865) 999-0212 -> 865.999.0212 (178) 165-8712 -> 178.165.8712

Test Case 2 Standard Input (307) 736-5739,(174) 558-x171,(572) 770-1891,(411) 496-9352,(865) 999-0212,(178) 165-8712

Enter a list of phone numbers separated by commas (307) 736-5739 -> 307.736.5739 (174) 558-x171 -> Subscriber number may only contain digits: x171 (572) 770-1891 -> 572.770.1891 (411) 496-9352 -> 411.496.9352 (865) 999-0212 -> 865.999.0212 (178) 165-8712 -> 178.165.8712

Test Case 3 Standard Input (307) 736-5739999,(174) 558-3171,(572) abc-1891,(411) 496-9352,(865) 9991-212,(178) 165-8712

Enter a list of phone numbers separated by commas (307) 736-5739999 -> Input must be exactly 14 characters (174) 558-3171 -> 174.558.3171 (572) abc-1891 -> Exchange may only contain digits: abc (411) 496-9352 -> 411.496.9352 (865) 9991-212 -> Exchange must be 3 characters long: 9991 (178) 165-8712 -> 178.165.8712

Test Case 4 Standard Input (3071) 76-5739,(174) 1558-171,(572- 770-1891,(411) 496e9352,!865) 999-0212,(178) 165-8712

Enter a list of phone numbers separated by commas (3071) 76-5739 -> Area code must be 3 characters long: 3071 (174) 1558-171 -> Exchange must be 3 characters long: 1558 (572- 770-1891 -> Missing character: ) (411) 496e9352 -> Missing character: - !865) 999-0212 -> Missing character: ( (178) 165-8712 -> 178.165.8712

Test Case 5 Standard Input (307) 736-5639,(174) 558-3171,(572) 770-1821,(411) 496-9312,(865) 929-0212,(178) 165-8712

Enter a list of phone numbers separated by commas (307) 736-5639 -> 307.736.5639 (174) 558-3171 -> 174.558.3171 (572) 770-1821 -> 572.770.1821 (411) 496-9312 -> 411.496.9312 (865) 929-0212 -> 865.929.0212 (178) 165-8712 -> 178.165.8712

Test Case 6 Standard Input (307) 736-1629,(174) 558-3171,(572) 770 1821,(411 496-9312,865) 929-0212,(178) 165-8322

Enter a list of phone numbers separated by commas (307) 736-1629 -> 307.736.1629 (174) 558-3171 -> 174.558.3171 (572) 770 1821 -> Missing character: - (411 496-9312 -> Missing character: ) 865) 929-0212 -> Input must be exactly 14 characters (178) 165-8322 -> 178.165.8322

Test Case 7 Standard Input a,b,c,d,e

Enter a list of phone numbers separated by commas a -> Input must be exactly 14 characters b -> Input must be exactly 14 characters c -> Input must be exactly 14 characters d -> Input must be exactly 14 characters e -> Input must be exactly 14 characters

Test Case 8 Standard Input (307) 736-5639,(174) 558-3171,(572)7270-1821,(411) 496-9312,(865) 92x-0212,(178) th6-8712

Enter a list of phone numbers separated by commas (307) 736-5639 -> 307.736.5639 (174) 558-3171 -> 174.558.3171 (572)7270-1821 -> Missing a space (411) 496-9312 -> 411.496.9312 (865) 92x-0212 -> Exchange may only contain digits: 92x (178) th6-8712 -> Exchange may only contain digits: th6

Explanation / Answer

I have done the second part. Just include your code in checknum function and it should work fine. If you face any issues reguarding mearging the code. Please let me know.

Also if you provide me your code will help you merge it.

Code :

#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <sstream>
#include <string.h>

using namespace std;

void checknum(char *number)
{
   cout<<number<<endl;
}

int main()
{
   char str[500];
   int count=0,c=0;
char *pt;
   cout<<"Enter list seperated by comma : ";
   gets(str);

   for (int i = 0; str[i]!=''; i++)
       if (str[i] == ',')
           count++;

   char *strArray[20];

   strArray[c] = strtok(str,",");
   while(strArray[c] != NULL)
       strArray[++c] = strtok(NULL,",");

   for (int i = 0; i <= count; i++)
   {
       checknum(strArray[i]);
   }

   return 0;
}

Please vote up if you are satisfied. Please ask your doubt if not satisfied.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote