-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathT9Spelling.java
More file actions
66 lines (60 loc) · 1.54 KB
/
T9Spelling.java
File metadata and controls
66 lines (60 loc) · 1.54 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//Created by sidhant
//03-04-2017
/*
Input
4
hi
yes
foo bar
output
hello world Case #1: 44 444
Case #2: 999337777
Case #3: 333666 6660 022 2777
Case #4: 4433555 555666096667775553
*/
import java.util.*;
public class keypad
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter the no of cases");
char ch2,ch1,ch,ch3;
int l,l1,c,o;
String y,f="";
int x=sc.nextInt();
String a[]={" ","","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
for(int i=1;i<=x;i++)
{
System.out.println("Enter the sentence");
y=sc.nextLine();
l=y.length();
for(int j=0;j<l-1;j++)
{
ch1=y.charAt(j);
ch2=y.charAt(j+1);
for(int k=0;k<10;k++)
{
l1=a[k].length();
for(int m=0;m<l1;m++)
{
ch=a[k].charAt(m);
if(ch==ch1)
{
for(int n=0;n<=m;n++)
f=f+k;
for(int n=0;n<=m;n++)
{
ch3=a[k].charAt(n);
if(ch2==ch3)
f=f+' ';
}
}
}
}
}
System.out.println(f);
f="";
}
}
}