Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package _03_RevisionMoreExcercises;
- import java.util.Scanner;
- public class _05_Messeges1 {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int n = Integer.parseInt(scanner.nextLine());
- for (int i = 1; i <= n; i++) {
- String input = scanner.nextLine();
- int numbersDigits = input.length();
- if (input.equals("0")) {
- System.out.print(" ");
- } else {
- int number = Integer.parseInt(input);
- int digit = number % 10;
- int offset = 0;
- if (digit == 8 || digit == 9) {
- offset = (digit - 2) * 3 + 1;
- } else {
- offset = (digit - 2) * 3;
- }
- int index = offset + numbersDigits - 1;
- System.out.print((char) (index + 97));
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement