Question: Write a Java program that inputs a ten-digit phone number, and then turns that ten- digit phone number into a more readable string with a

Write a Java program that inputs a ten-digit phone number, and then turns that ten- digit phone number into a more readable string with a pair of parentheses, a dash, and a space.

For example, if the user enters the value 5147447500 as input, your program should print the string (514) 744-7500.

Hint use integer division and integer remainder operations to compute the three required blocks of numbers: area code 514, prefix 744, and line number 7500.

For example, in Java, 5147447500L/ 10000000 is equal to 514.

A sample run of your program should produce the following output, where the users input is shown inredfor clarity:

Enter a 10-digit phone-number: 5147447500

area code:514

prefix : 744

line number: 7500

PhoneNumber:(514) 744-7500

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!