Question
Complete the following questions in C++: Question 1 Prompt the user for a phone number that's in the following format: (AAA) BBB-CCCC AAA is the
Complete the following questions in C++:
Question 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
View required output
Test Case 1
Standard Input |
---|
(8055) 922-666 |
Enter a phone number in the following format: (XXX) XXX-XXXX (8055) 922-666 -> Area code must be 3 characters long: 8055
Test Case 2
Standard Input |
---|
(8805) 922-696 |
Enter a phone number in the following format: (XXX) XXX-XXXX (8805) 922-696 -> Area code must be 3 characters long: 8805
Test Case 3
Standard Input |
---|
(3) 922-6966456 |
Enter a phone number in the following format: (XXX) XXX-XXXX (3) 922-6966456 -> Input must be exactly 14 characters
Test Case 4
Standard Input |
---|
(x05) 922-6966 |
Enter a phone number in the following format: (XXX) XXX-XXXX (x05) 922-6966 -> Area code may only contain digits: x05
Test Case 5
Standard Input |
---|
(8x5) 922-6966 |
Enter a phone number in the following format: (XXX) XXX-XXXX (8x5) 922-6966 -> Area code may only contain digits: 8x5
Test Case 6
Standard Input |
---|
(80x) 922-6966 |
Enter a phone number in the following format: (XXX) XXX-XXXX (80x) 922-6966 -> Area code may only contain digits: 80x
Test Case 7
Standard Input |
---|
(805) 92226966 |
Enter a phone number in the following format: (XXX) XXX-XXXX (805) 92226966 -> Missing character: -
Test Case 8
Standard Input |
---|
(805) 9221-966 |
Enter a phone number in the following format: (XXX) XXX-XXXX (805) 9221-966 -> Exchange must be 3 characters long: 9221
Test Case 9
Standard Input |
---|
(805) 1-966222 |
Enter a phone number in the following format: (XXX) XXX-XXXX (805) 1-966222 -> Exchange must be 3 characters long: 1
Test Case 10
Standard Input |
---|
(805) 12-66222 |
Enter a phone number in the following format: (XXX) XXX-XXXX (805) 12-66222 -> Exchange must be 3 characters long: 12
Test Case 11
Standard Input |
---|
(805) x22-6966 |
Enter a phone number in the following format: (XXX) XXX-XXXX (805) x22-6966 -> Exchange may only contain digits: x22
Test Case 12
Standard Input |
---|
(805) 9x2-6966 |
Enter a phone number in the following format: (XXX) XXX-XXXX (805) 9x2-6966 -> Exchange may only contain digits: 9x2
Test Case 13
Standard Input |
---|
(805) 92x-6966 |
Enter a phone number in the following format: (XXX) XXX-XXXX (805) 92x-6966 -> Exchange may only contain digits: 92x
Test Case 14
Standard Input |
---|
(805) 922-6232 |
Enter a phone number in the following format: (XXX) XXX-XXXX (805) 922-6232 -> 805.922.6232
Test Case 15
Standard Input |
---|
(123) 456-7890 |
Enter a phone number in the following format: (XXX) XXX-XXXX (123) 456-7890 -> 123.456.7890
Test Case 16
Standard Input |
---|
(888) 888-7890 |
Enter a phone number in the following format: (XXX) XXX-XXXX (888) 888-7890 -> 888.888.7890
Test Case 17
Standard Input |
---|
abc |
Enter a phone number in the following format: (XXX) XXX-XXXX abc -> Input must be exactly 14 characters
Test Case 18
Standard Input |
---|
123) 456-7890 |
Enter a phone number in the following format: (XXX) XXX-XXXX 123) 456-7890 -> Input must be exactly 14 characters
Test Case 19
Standard Input |
---|
(123) 456 7890 |
Enter a phone number in the following format: (XXX) XXX-XXXX (123) 456 7890 -> Missing character: -
Test Case 20
Standard Input |
---|
(805) 922-x966 |
Enter a phone number in the following format: (XXX) XXX-XXXX (805) 922-x966 -> Subscriber number may only contain digits: x966
Test Case 21
Standard Input |
---|
(805) 922-9y66 |
Enter a phone number in the following format: (XXX) XXX-XXXX (805) 922-9y66 -> Subscriber number may only contain digits: 9y66
Test Case 22
Standard Input |
---|
(805) 922-99z6 |
Enter a phone number in the following format: (XXX) XXX-XXXX (805) 922-99z6 -> Subscriber number may only contain digits: 99z6
Test Case 23
Standard Input |
---|
(805) 922-196a |
Enter a phone number in the following format: (XXX) XXX-XXXX (805) 922-196a -> Subscriber number may only contain digits: 196a
--------------------------------------------------------------------------------------------------------------------------------------------
Question 2
Prompt the user for a list of phone numbers separated by commas. User the validation rules from the last question.
View required output
Test Case 1
Standard Input |
---|
(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
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