Advertisement
Ivelin_Arsov

English Name of the Last Digit

Mar 25th, 2020
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.19 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class EnglishNameOfTheLastDigit {
  4.     public static void main(String[] args) {
  5.         Scanner scan = new Scanner(System.in);
  6.         int number = Integer.parseInt(scan.nextLine());
  7.         int lastDigit =Math.abs(number % 10);
  8.         switch (lastDigit) {
  9.             case 0:
  10.                 System.out.println("zero");
  11.                 break;
  12.             case 1:
  13.                 System.out.println("one");
  14.                 break;
  15.             case 2:
  16.                 System.out.println("two");
  17.                 break;
  18.             case 3:
  19.                 System.out.println("three");
  20.                 break;
  21.             case 4:
  22.                 System.out.println("for");
  23.                 break;
  24.             case 5:
  25.                 System.out.println("five");
  26.                 break;
  27.             case 6:
  28.                 System.out.println("six");
  29.                 break;
  30.             case 7:
  31.                 System.out.println("seven");
  32.                 break;
  33.             case 8:
  34.                 System.out.println("eight");
  35.                 break;
  36.             case 9:
  37.                 System.out.println("nine");
  38.                 break;
  39.         }
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement