desislava_topuzakova

Untitled

Sep 25th, 2021
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Messages {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6. int typing = Integer.parseInt(scanner.nextLine());
  7. String result = "";
  8. String input;
  9. int digitsLength ;
  10. int digitMain;
  11. int letterIndex;
  12. for (int i = 0; i < typing ; i++) {
  13. input = scanner.nextLine();
  14. digitsLength = input.length();
  15. digitMain = Integer.parseInt(input) % 10;
  16. if (digitMain > 1) {
  17. letterIndex = 97 + ((digitMain - 2) * 3) + digitsLength - 1;
  18. if (digitMain > 7) letterIndex++;
  19. } else {
  20. letterIndex = digitMain == 0 ? 32 : 0;
  21. }
  22. result = result + (char)letterIndex;
  23. }
  24. System.out.println(result);
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment