-
Notifications
You must be signed in to change notification settings - Fork 1
/
KeyPad.java
37 lines (35 loc) · 982 Bytes
/
KeyPad.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
public class KeypadPro {
private static Scanner s;
public static void main(String[] args) {
int temp1;
s = new Scanner(System.in);
Map<String, String> m = new HashMap<String, String>();
m.put("2", "ABC");
m.put("3", "DEF");
m.put("4", "GHI");
m.put("5", "JKL");
m.put("6", "MNO");
m.put("7", "PQRS");
m.put("8", "TUV");
m.put("9", "WXYZ");
System.out.println("Keypad Word Project");
System.out.println("Enter the Number");
String s0 = s.nextLine();
StringBuffer s1 = new StringBuffer(s0);
String s2 = s1.reverse().toString();
int a = Integer.parseInt(s2);
if (s1.equals("1") || s1.equals("*") || s1.equals("#")) {
System.out.println("No Equivalent Key Found");
} else {
System.out.println("The Key Equivalent for " + s0 + " is/are : ");
while (a > 0) {
temp1 = a % 10;
System.out.print(m.get(Integer.toString(temp1)));
a = a / 10;
}
}
}
}