Hey guys, I'm working on a program and I'm stuck. This particular program is supposed to prompt the user to input either an uppercase or lowercase Y to process a phone number, they are then prompted to enter the character representation of a phone number (like CALL HOME would be 225-5466), this repeats until the user enters something other than the letter Y. All of the words entered are to be stored into a single array. The program is then to convert these words in the array to actual phone numbers. I'm kind of confused as to how to set this up. Here is what I have so far.
import java.util.*; public class Program1 { public static void main(String[] args) { Scanner input = new Scanner(System.in); String begin; int phoneNumber = number.convertNum(); System.out.println("Please enter an uppercase or lowercase Y when you are ready to enter a telephone number: "); begin = input.next(); while (begin.equals("y") || begin.equals("Y")) { System.out.println("Please enter a telephone number expressed in letters: "); String letters = input.next(); char[] phoneArray = letters.toCharArray(); System.out.println("Please enter an uppercase or lowercase Y when you are ready to enter a telephone number: "); begin = input.next(); } System.out.println("Here is the numeric representation of the phone number(s) you entered"); } public static int convertNum(char[] phoneArray) { return number; } }
I realize that the second method doesn't have anything to return yet, I just wanted to put that in there while I was doing things that I actually know how to do ha. The convertNum() method is supposed to be the method with which the array of characters is converted to phone numbers.
I'm still trying to think my way through this. I would think it'd be easier to store the inputs from the user as individual letters rather than words for the sake of converting to phone numbers.
Also, we are only supposed to recognize the first 7 letters of each word that is entered, like the CALL HOME example, there are 8 letters but it's still a seven digit phone number, so I'm not sure how that would work.
Also, when printing the phone numbers after they've been converted, we're supposed to print the hyphen after the third number, I have no clue how that would be done from an array.
I was actually feeling pretty good about this program until I reached this point ha. Any help would be greatly appreciated.