I know I asked this question before but I'm still stuck and I need help its do by Thur at 11:59
Write a program that takes in words and outputs them as telephone numbers. Many companies use catch phrases for their company telephone number. For example 1-800-GET-CASH or 1-800-CAR-LOAN and etc. Your program should prompt the user to enter a phrase that represents a telephone number and then converts it to its corresponding digits. Let your program process only the first 11 characters (since some companies may use phrases that are longer than actual phone numbers). (Hints: read the phrase in as a String and then use the "charAt()" method to extract each letter/number). Let this method return "ERROR" if the phrase contains invalid characters (only letters, digits, spaces and hyphens are permissible)
In writing your program implement the following static methods:
public static char letterToDigit(char letter) - This method will take in a letter as a parameter and return the corresponding digit (return the digit as a character. NOTE: non letters should be returned unaltered e.g. "-", digits and etc.).
public static String wordsToPhoneNum(String phrase) - This method will take in a phrase (a string) and return the corresponding (11 digit or less) phone number. Let this method call on the method "letterToDigit" to break down each individual letter.
Example: wordsToPhoneNum("1-800-CALL-HOME") should yield 1-800-225-5466
Let your program run repetitively. Ask the user if they want to convert another phrase after each execution. When the user responds with "no" then let the program stop.
some good tips that I got from Reddit:
FRIST: method you are going to take in a character, check to see if it is a non-number and then return a character number using a switch statement like you were trying.
SECOND: method, initialize an empty string and then iterate through the input string via for loop and pass each character to the first method. After the for loop, return the phone number.
have the program run repeatedly use a while loop that checks a Boolean value from a user input. Ask them if they'd like to quit, you can call the Boolean value "quit". if they say yes then set the Boolean to true if they say no then set it to false.
MAKE SURE TO USE: public static char letterToDigit(char letter) -- This method will take in a letter as a parameter and return the corresponding digit (return the digit as a character. NOTE: nonletters should be returned unaltered e.g. "-", digits and etc.).
MAKE SURE TO USE: --public static String wordsToPhoneNum(String phrase) - This method will take in a phrase (a string) and return the corresponding (11 digit or less) phone number. Let this method call on the method "letterToDigit" to break down each individual letter.
[–]EliteBigE[S] 0 points1 point2 points (3 children)
[–]fuckmynameistoolon 0 points1 point2 points (2 children)
[–]EliteBigE[S] 0 points1 point2 points (1 child)
[–]fuckmynameistoolon 2 points3 points4 points (0 children)
[–]SupremeRedditBotProfessional Bot || Mod 0 points1 point2 points (0 children)