Skip to content
Advertisement

Phone number breakdown (International Version) java

Given a long integer representing a 11-digit phone number, output the country code, area code, prefix, and line number using the format +1 (800) 555-1212.

Ex: If the input is: 18005551212

the output is:

+1 (800) 555-1212

So far,

JavaScript

I am running program just to see how I want to go about for the rest.

I have a question. After running, how can I remove the 1 in and for the area_Code?

It appears like this (1800), I want to place the 1 outside the parentheses.

Any help please, kind of newbie still.

Advertisement

Answer

to output 800 you can use : area_Code % 1000 and to output the 1 you can use : area_Code / 1000

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement