To make telephone number easier to remember, some companies useletters to show t
ID: 3614463 • Letter: T
Question
To make telephone number easier to remember, some companies useletters to show their telephone number. For example, the telephonenumber 438-5626 can be shown as GET-LOAN. In some cases, to make atelephone number meaningful, companies might use more than sevenletters. For example, 225-5466 can be displayed as CALL-HOME, whichuses eight letters. Write a program that prompts the user to entera telephone number expressed in letters and outputs thecorresponding telephone numbers in digits.If the user enters morethan eight letters, then process only the first seven letters.Also, output the-(hyphen) after the third digit. Allow the user touse uppercase and lowercase letters, as well as spaces betweenwords. Moreover, your program should process as many telephonenumbers as the user wants.(Hint: You can read the entered telephone number as a string andthen use the charAt method of the class String toextract each character. For example, if str refersto a string, then the expression str.charAt (i)returns the character at the ith position. Recall that ina string, the position of the first character is 0.)
Explanation / Answer
please rate - thanks import java.util.*; public class untitled2 { public static void main(String[] args) {String number; int i=0,j=0; char c; Scanner in=new Scanner (System.in); System.out.println("Enter the phone number: "); number=in.nextLine(); number=number.toUpperCase(); c=number.charAt(i); while(c!=' '&&jRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.