import java.util.*;
import javax.swing.*;
public class TelephoneNumber2
{
static Scanner console = new Scanner(System.in);
public static void main(String[] args)
{
String inputStr, lowerCase, preStr, postStr, phrase1;
int hyphenIndex, i, j = 0, k, l = 0, h, length, preLength, postLength, num = 0;
char character, character2;
//System.out.println("Please enter the phone number as a phrase(including hyphen): ");
JOptionPane jop = new JOptionPane();
inputStr = jop.showInputDialog("Please enter the phone number as a phrase(including hyphen): ");
//inputStr = console.next();
lowerCase = inputStr.toLowerCase();
hyphenIndex = lowerCase.indexOf('-');
length = lowerCase.length();
preStr = lowerCase.substring(0, hyphenIndex);
postStr = lowerCase.substring(hyphenIndex + 1, length);
preLength = preStr.length();
postLength = postStr.length();
//System.out.print("The phone number is: ");
phrase1 = "The phone number is: ";
if(preLength == 3)
{
i = preLength - 1;
while(i >= 0)
{
character = preStr.charAt(j);
i--;
j++;
switch(character)
{
case 'a':
case 'b':
case 'c':
num = 2;
break;
case 'd':
case 'e':
case 'f':
num = 3;
break;
case 'g':
case 'h':
case 'i':
num = 4;
break;
case 'j':
case 'k':
case 'l':
num = 5;
break;
case 'm':
case 'n':
case 'o':
num = 6;
break;
case 'p':
case 'q':
case 'r':
case 's':
num = 7;
break;
case 't':
case 'u':
case 'v':
num = 8;
break;
case 'w':
case 'x':
case 'y':
case 'z':
num = 9;
break;
}
//System.out.print(num);
jop.showMessageDialog(null, num, "tele", jop.INFORMATION_MESSAGE);
}
//System.out.print("-");
jop.showMessageDialog(null, "-", "tele", jop.INFORMATION_MESSAGE);
}
else
{
j = 0;
i = 2;
while(i >= 0)
{
character = preStr.charAt(j);
i--;
j++;
switch(character)
{
case 'a':
case 'b':
case 'c':
num = 2;
break;
case 'd':
case 'e':
case 'f':
num = 3;
break;
case 'g':
case 'h':
case 'i':
num = 4;
break;
case 'j':
case 'k':
case 'l':
num = 5;
break;
case 'm':
case 'n':
case 'o':
num = 6;
break;
case 'p':
case 'q':
case 'r':
case 's':
num = 7;
break;
case 't':
case 'u':
case 'v':
num = 8;
break;
case 'w':
case 'x':
case 'y':
case 'z':
num = 9;
break;
}
//System.out.print(num);
jop.showMessageDialog(null, num, "tele", jop.INFORMATION_MESSAGE);
}
//System.out.print("-");
jop.showMessageDialog(null, "-", "tele", jop.INFORMATION_MESSAGE);
}
h = preLength - 4;
j = 3;
while(h >= 0)
{
character = preStr.charAt(j);
h--;
j++;
switch(character)
{
case 'a':
case 'b':
case 'c':
num = 2;
break;
case 'd':
case 'e':
case 'f':
num = 3;
break;
case 'g':
case 'h':
case 'i':
num = 4;
break;
case 'j':
case 'k':
case 'l':
num = 5;
break;
case 'm':
case 'n':
case 'o':
num = 6;
break;
case 'p':
case 'q':
case 'r':
case 's':
num = 7;
break;
case 't':
case 'u':
case 'v':
num = 8;
break;
case 'w':
case 'x':
case 'y':
case 'z':
num = 9;
break;
}
//System.out.print(num);
jop.showMessageDialog(null, num, "tele", jop.INFORMATION_MESSAGE);
}
k = 6 - preLength;
while(k >= 0)
{
character2 = postStr.charAt(l);
k--;
l++;
switch(character2)
{
case 'a':
case 'b':
case 'c':
num = 2;
break;
case 'd':
case 'e':
case 'f':
num = 3;
break;
case 'g':
case 'h':
case 'i':
num = 4;
break;
case 'j':
case 'k':
case 'l':
num = 5;
break;
case 'm':
case 'n':
case 'o':
num = 6;
break;
case 'p':
case 'q':
case 'r':
case 's':
num = 7;
break;
case 't':
case 'u':
case 'v':
num = 8;
break;
case 'w':
case 'x':
case 'y':
case 'z':
num = 9;
break;
}
//System.out.print(num);
jop.showMessageDialog(null, num, "tele", jop.INFORMATION_MESSAGE);
}
}
}