Ok so i have this work for my java class done so far. And i cannot figure out how to get the different letters from an inputted word to output as a number. The assignment is get a user to input a 7 letter word and output it as a phone number. The code I have is crap I'm sure but yeah.
import java.util.*;
import javax.swing.JOptionPane;
import java.lang.*;
public class Veneski_Chp5
{
static Scanner console = new Scanner(System.in);
public static void main(String[] args)
{
char letter1;
String inputMessage;
String inputString;
String outputMessage;
int outputWord;
inputMessage = "Enter in a word to be converted to a phone number";
inputString = JOptionPane.showInputDialog(inputMessage);
letter1 = inputString.charAt(0);
letter2 = inputString.charAt(1);
letter3 = inputString.charAt(2);
letter4 = inputString.charAt(3);
letter5 = inputString.charAt(4);
letter6 = inputString.charAt(5);
letter7 = inputString.charAt(6);
while (letter1 != '#' )
{
outputMessage = "The word you entered is: "
+ inputString + "\n"
+ "The Phone number corresponding with that word is: ";
if (letter1 >= 'A' && letter1 >= 'Z')
{
switch (letter1)
{
case 'A':
case 'B':
case 'C':
case 'a':
case 'b':
case 'c':
char letter1Num2;
letter1 = letter1Num2;
break;
case 'D':
case 'E':
case 'F':
case 'd':
case 'e':
case 'f':
char letter1Num3;
letter1 = letter1Num3;
break;
case 'G':
case 'H':
case 'I':
case 'g':
case 'h':
case 'i':
char letter1Num4;
letter1 = letter1Num4;
break;
case 'J':
case 'K':
case 'L':
case 'j':
case 'k':
case 'l':
char letter1Num5;
letter1 = letter1Num5;
break;
case 'M':
case 'N':
case 'O':
case 'm':
case 'n':
case 'o':
char letter1Num6;
letter1 = letter1Num6;
break;
case 'P':
case 'Q':
case 'R':
case 'S':
case 'p':
case 'q':
case 'r':
case 's':
char letter1Num7;
letter1 = letter1Num7;
break;
case 'T':
case 'U':
case 'V':
case 't':
case 'u':
case 'v':
char letter1Num8;
letter1 = letter1Num8;
break;
case 'W':
case 'X':
case 'Y':
case 'Z':
case 'w':
case 'x':
case 'y':
case 'z':
char letter1Num9;
letter1 = letter1Num9;
break;
}
}
else
outputMessage = outputMessage + "Invaild Input";
outputWord = Character.Digit(letter1, 10);
JOptionPane.showMessageDialog(null, outputWord);
}
System.exit(0);
}
}