Purchase Solution

Java program to dissect phone numbers

Not what you're looking for?

Ask Custom Question

Implement a Java 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.

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.

Do 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).

A sample session would look like following.

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:
Q
Press any key to continue . . .

Attachments
Purchase this Solution

Solution Summary

Code has been tested working using the sample session inputs.

Purchase this Solution


Free BrainMass Quizzes
Javscript Basics

Quiz on basics of javascript programming language.

Basic UNIX commands

Use this quiz to check your knowledge of a few common UNIX commands. The quiz covers some of the most essential UNIX commands and their basic usage. If you can pass this quiz then you are clearly on your way to becoming an effective UNIX command line user.

Basic Networking Questions

This quiz consists of some basic networking questions.

Java loops

This quiz checks your knowledge of for and while loops in Java. For and while loops are essential building blocks for all Java programs. Having a solid understanding of these constructs is critical for success in programming Java.

Word 2010: Tables

Have you never worked with Tables in Word 2010? Maybe it has been a while since you have used a Table in Word and you need to brush up on your skills. Several keywords and popular options are discussed as you go through this quiz.