SHOW:
|
|
- or go back to the newest paste.
1 | import java.util.Scanner; | |
2 | ||
3 | public class O5Message { | |
4 | public static void main(String[] args) { | |
5 | Scanner scanner = new Scanner(System.in); | |
6 | ||
7 | int numbersOfPush = Integer.parseInt(scanner.nextLine()); | |
8 | ||
9 | String message = ""; | |
10 | ||
11 | for (int i = 0; i < numbersOfPush; i++) { | |
12 | String digits = scanner.nextLine(); | |
13 | int digitLength = digits.length(); | |
14 | char oneDigit = digits.charAt(0); | |
15 | int mainDigit = Character.getNumericValue(oneDigit); | |
16 | int offset = (mainDigit - 2) * 3; | |
17 | if (mainDigit == 8 || mainDigit == 9) { | |
18 | offset = (mainDigit - 2) * 3 + 1; | |
19 | } | |
20 | int letterIndex = offset + digitLength - 1; | |
21 | int letterCode = letterIndex + 97; | |
22 | ||
23 | ||
24 | char letter = (char) letterCode; | |
25 | if (mainDigit == 0) { | |
26 | letter = (char) (mainDigit + 32); | |
27 | } | |
28 | message += letter; | |
29 | ||
30 | ||
31 | } | |
32 | System.out.println(message); | |
33 | ||
34 | } | |
35 | } |