In Java Implement a program that reads phone numbers, and for each phone number, it displays the phone number’s three components – country code, area code, and local number. See the sample session for details. You may assume that the user enters each phone number as a series of digits and dashes, such that there are three groups of digits and two dashes separating the three groups. For example, 1--816--7412000. The first digit group (1 in the example) is the country code, the second digit group (816 in the example) is the area code, and the third digit group (7412000 in the example) is the local phone number. You may not assume that the number of digits in a particular digit group is fixed. For example, the country code for the United States requires one digit (1) and the country code for China requires two digits (86). Your program should repeatedly prompt the user for phone numbers until the user enters "q". The program terminates when the user enters the "q". The program should perform input validation for the user’s phone numbers (only numbers are acceptable).  Sample session: PHONE NUMBER DISSECTOR Enter a phone number in the form cc—area--local, where cc = country code digits, area = area code digits, and local = local phone digits. Or enter q to quit: 1—816--7412000 country code = 1 area code = 816 local phone number = 7412000 Enter a phone number in the form cc-area-local, where cc = country code digits, area = area code digits, and local = local phone digits. Or enter q to quit: 86—131--12345678 country code = 86 area code = 131 local phone number = 12345678 Enter a phone number in the form cc-area-local, where cc = country code digits, area = area code digits, and local = local phone digits. Or enter q to quit: aa-123-12345555 invalid input Enter a phone number in the form cc-area-local, where cc = country code digits, area = area code digits, and local = local phone digits. Or enter q to quit: Q

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

In Java

Implement a program that reads phone numbers, and for each phone number, it
displays the phone number’s three components – country code, area code, and local
number. See the sample session for details.
You may assume that the user enters each phone number as a series of digits and
dashes, such that there are three groups of digits and two dashes separating the three
groups. For example, 1--816--7412000. The first digit group (1 in the example) is the
country code, the second digit group (816 in the example) is the area code, and the
third digit group (7412000 in the example) is the local phone number.
You may not assume that the number of digits in a particular digit group is fixed. For
example, the country code for the United States requires one digit (1) and the country
code for China requires two digits (86).
Your program should repeatedly prompt the user for phone numbers until the user
enters "q". The program terminates when the user enters the "q".
The program should perform input validation for the user’s phone numbers (only
numbers are acceptable). 

Sample session:

PHONE NUMBER DISSECTOR
Enter a phone number in the form cc—area--local,
where cc = country code digits, area = area code digits,
and local = local phone digits.
Or enter q to quit:
1—816--7412000
country code = 1
area code = 816
local phone number = 7412000
Enter a phone number in the form cc-area-local,
where cc = country code digits, area = area code digits,
and local = local phone digits.
Or enter q to quit:
86—131--12345678
country code = 86
area code = 131
local phone number = 12345678
Enter a phone number in the form cc-area-local,
where cc = country code digits, area = area code digits,
and local = local phone digits.
Or enter q to quit:
aa-123-12345555
invalid input
Enter a phone number in the form cc-area-local,
where cc = country code digits, area = area code digits,
and local = local phone digits.
Or enter q to quit:
Q

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Developing computer interface
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
Recommended textbooks for you
Database System Concepts
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)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education