Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Canadian phone number has the following format: +1 (NPA) NXX-XXXX Country Area Code Code Prefix Subscriber Area Code Three digits starting with 2-9 Prefix=

Canadian phone number has the following format: +1 (NPA) NXX-XXXX Country Area Code Code Prefix Subscriber Area Code Three digits starting with 2-9 Prefix= Three digits starting with 2-9 Subscriber= Any four digits 0-9 Write a java program, using loops, that asks the user to enter a phone number then if correct print the Area Code, Prefix, and Subscriber numbers. If not correct, print what is wrong. Sample run: Enter a number or -99 to quit: +1 (604) 277-9999 The number is correct with area code: 604, prefix 277, and subscriber 9999 Enter a number or -99 to quit: 1 (104) 277-0123 Country code doesn't start with + and area code doesn't start with a 2-9 number. Enter a number or -99 to quit: 1 (104) 177-7634 Country code doesn't start with + and area code and prefix don't start with a 2-9 number. Enter a number or -99 to quit: +2 (104) 166-9876 Country code is not 1 and area code and prefix don't start with a 2-9 number. Enter a number or -99 to quit: +2 (104) 777-3377 Country code is not 1 b and area code doesn't start with a 2-9 number Enter a number or -99 to quit: +2 (604) 177-2854 Country code is not 1 b and prefix doesn't start with a 2-9 number. Enter a number or -99 to quit: +1 (604) 277-12345 Subscriber number is more than 4 digits Enter a number or -99 to quit: -99 The program is ending

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

Income Tax Fundamentals 2013

Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill

31st Edition

1111972516, 978-1285586618, 1285586611, 978-1285613109, 978-1111972516

More Books

Students also viewed these Programming questions