Answer:
In Python:
phonenum = int(input("10 digit phone number: "))
last4 = phonenum%10000
phonenum//=10000
mid3 = phonenum%1000
phonenum = phonenum//1000
newnum = str(phonenum)+"-"+str(mid3)+"-"+str(last4)
print("New: "+str(newnum))
Step-by-step explanation:
This prompts the user for phone number
phonenum = int(input("10 digit phone number: "))
This gets the last 4 of the phone number using % operator
last4 = phonenum%10000
This shifts the phone number by 4 digit right
phonenum//=10000
This gets the middle 3 of the phone number using % operator
mid3 = phonenum%1000
This shifts the phone number by 3 digit right
phonenum = phonenum//1000
This generates the new phone number which includes the area code...
newnum = str(phonenum)+"-"+str(mid3)+"-"+str(last4)
This prints the formatted phone number
print("New: "+str(newnum))