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
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