Advertisement
marking2112

JavaTechExercise

Oct 1st, 2018
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.97 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Test {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         int num = Integer.parseInt(scanner.nextLine());
  8.         lastDigit(num);
  9.     }
  10.     public static void lastDigit (int num) {
  11.         int number = (num);
  12.         int lastDigit = number % 10;
  13.         if (lastDigit == 1){
  14.             System.out.println("One");
  15.         } else if (lastDigit == 2) {
  16.             System.out.println("Two");
  17.         } else if (lastDigit == 3) {
  18.             System.out.println("Three");
  19.         } else if (lastDigit == 5) {
  20.             System.out.println("Five");
  21.         } else if (lastDigit == 6) {
  22.             System.out.println("Six");
  23.         } else if (lastDigit == 7) {
  24.             System.out.println("Seven");
  25.         } else if (lastDigit == 8) {
  26.             System.out.println("Eight");
  27.         } else if (lastDigit == 9) {
  28.             System.out.println("Nine");
  29.         }
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement