Guest User

Untitled

a guest
May 5th, 2018
140
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Scanner;
  2.  
  3. public class Task16 {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6. int num = Integer.parseInt(scanner.nextLine());
  7. int n1 = num/10;
  8. int n2 = num%10;
  9. String s2 ="";
  10. if(n2==0) s2 = "zero";
  11. else if(n2==1) s2= "one";
  12. else if(n2==2) s2= "two";
  13. else if(n2==3) s2= "three";
  14. else if(n2==4) s2= "four";
  15. else if(n2==5) s2= "five";
  16. else if(n2==6) s2= "six";
  17. else if(n2==7) s2= "seven";
  18. else if(n2==8) s2= "eight";
  19. else if(n2==9) s2= "nine";
  20.  
  21. if(num<0||num>100) System.out.println("invalid number");
  22. else if(n1==0) System.out.printf("%s",s2);
  23. else if(n1==1&&n2==0) System.out.println("ten");
  24. else if(n1==1&&n2==1) System.out.println("eleven");
  25. else if(n1==1&&n2==2) System.out.println("twelve");
  26. else if(n1==1&&n2==3) System.out.println("thirteen");
  27. else if(n1==1&&n2==5) System.out.println("fifteen");
  28. else if(n1==1) System.out.printf("%steen",s2);
  29. else if(n1==2&&n2==0) System.out.println("twenty");
  30. else if(n1==2) System.out.printf("twenty %s",s2);
  31. else if(n1==3&&n2==0) System.out.println("thirty");
  32. else if (n1==3) System.out.printf("thirty %s",s2);
  33. else if(n1==4&&n2==0) System.out.println("forty");
  34. else if (n1==4) System.out.printf("forty %s",s2);
  35. else if(n1==5&&n2==0) System.out.println("fifty");
  36. else if (n1==5) System.out.printf("fifty %s",s2);
  37. else if(n1==6&&n2==0) System.out.println("sixty");
  38. else if (n1==6) System.out.printf("sixty %s",s2);
  39. else if(n1==7&&n2==0) System.out.println("seventy");
  40. else if (n1==7) System.out.printf("seventy %s",s2);
  41. else if(n1==8&&n2==0) System.out.println("eighty");
  42. else if (n1==8) System.out.printf("eighty %s",s2);
  43. else if(n1==9&&n2==0) System.out.println("ninety");
  44. else if (n1==9) System.out.printf("ninety %s",s2);
  45. else if (n1==10) System.out.println("one hundred");
  46.  
  47. }
  48. }
RAW Paste Data