Advertisement
SvetlanPetrova

English Name Of The Last Digit

May 30th, 2021
1,413
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.29 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class EnglishNameOfTheLastNumber {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         String numberAsString = scanner.nextLine();
  8.  
  9.         char lastDigit = numberAsString.toCharArray()[numberAsString.length() - 1];
  10.         String output;
  11.  
  12.         switch (lastDigit) {
  13.             case '0':
  14.                 output = "zero";
  15.                 break;
  16.             case '1':
  17.                 output = "one";
  18.                 break;
  19.             case '2':
  20.                 output = "two";
  21.                 break;
  22.             case '3':
  23.                 output = "three";
  24.                 break;
  25.             case '4':
  26.                 output = "four";
  27.                 break;
  28.             case '5':
  29.                 output = "five";
  30.                 break;
  31.             case '6':
  32.                 output = "six";
  33.                 break;
  34.             case '7':
  35.                 output = "seven";
  36.                 break;
  37.             case '8':
  38.                 output = "eight";
  39.                 break;
  40.             case '9':
  41.                 output = "nine";
  42.                 break;
  43.  
  44.             default:
  45.                 output = null;
  46.                 break;
  47.         }
  48.  
  49.         System.out.println(output);
  50.     }
  51. }
  52.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement