Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please use Java, Thank you. 5-5 To make telephone numbers easier to remember, some companies use letters to represent their telephone number. For example, using

Please use Java, Thank you. 5-5
image text in transcribed
image text in transcribed
To make telephone numbers easier to remember, some companies use letters to represent their telephone number. For example, using letters, the telephone number 438-5626 can be represented as GET LOAN. In some cases, to make a telephone number meaningful, companies might use more than seven letters. For example 225-5466 can be displayed as CALL HOME, which uses eight letters. Write a program that prompts the user to enter a telephone number expressed in letters and outputs the corresponding telephone number in digits. If the user enters more than seven letters (spaces do not count), then process only the first seven letters and ignore the rest. Your program should also output the - (hyphen) after the third digit. Allow the user to use uppercase and lowercase letters, as well as spaces between the words. Hint1: You can use the charAt method of the class String to extract each character. For example, if str refers to a String variable, then the expression str.charAt(i) returns the character at the ith position of str. Recall that in a String, the positiori of the first character is 0. Hint2: You can use the toUpperCase or toLowerCase method of the class String to convert all chars in the String to upper or lower case. Hint 3: You can use the following table for your conversion: If the user enters: Get Loan Your program will output: 4385626 If the user enters: cAll HoMe Your program will output: 2255466 Your prompt to the user should be: Please enter a telephone number using letters : Please note that your class should be named TelephoneNumber

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases Demystified

Authors: Andrew Oppel

1st Edition

0072253649, 9780072253641

More Books

Students also viewed these Databases questions

Question

Question What is the doughnut hole in HSA coverage?

Answered: 1 week ago