borkins

05b. Number 0..9 to Text

Mar 23rd, 2017
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.96 KB | None | 0 0
  1. /*
  2.  * Simple Conditions
  3.  */
  4. import java.util.Scanner;
  5.  
  6. public class _05b_Number_0_9_toText
  7. {
  8.     public static void main(String[] args)
  9.     {
  10.         Scanner scan = new Scanner(System.in);
  11.  
  12.         int num = Integer.parseInt(scan.nextLine());
  13.        
  14.         // Using switch-case condition to print the result
  15.         switch (num)
  16.         {
  17.             case 0: System.out.println("zero"); break;
  18.             case 1: System.out.println("one"); break;
  19.             case 2: System.out.println("two"); break;
  20.             case 3: System.out.println("three"); break;
  21.             case 4: System.out.println("four"); break;
  22.             case 5: System.out.println("five"); break;
  23.             case 6: System.out.println("six"); break;
  24.             case 7: System.out.println("seven"); break;
  25.             case 8: System.out.println("eight"); break;
  26.             case 9: System.out.println("nine"); break;
  27.             default: System.out.println("number too big");
  28.         }
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment