-
Notifications
You must be signed in to change notification settings - Fork 0
/
10921.java
41 lines (33 loc) · 967 Bytes
/
10921.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
38
39
40
41
import java.util.*;
import java.lang.*;
public class Main{
public static void main(String args[])
{
Scanner read = new Scanner(System.in);
while(read.hasNext())
{
String num="";
String telephoneNum = read.nextLine();
for(int i=0;i<telephoneNum.length();i++)
{
char ch=telephoneNum.charAt(i);
if(ch>='A' && ch<='C')
num+='2';
else if(ch>='D' && ch<='F')
num+='3';
else if(ch>='G' && ch<='I')
num+='4';
else if(ch>='J' && ch<='L')
num+='5';
else if(ch>='M' && ch<='O')
num+='6';
else if(ch>='P' && ch<='S') num+='7';
else if(ch>='T' && ch<='V') num+='8';
else if(ch>='W' && ch<='Z') num+='9';
else num+=ch;
}
System.out.println(num);
}
read.close();
}
}