Advertisement
Ronka

Untitled

Jan 17th, 2017
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.36 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. /**
  4. * Created by ValioHP on 16.1.2017 г..
  5. */
  6. public class num {
  7. public static void main(String[] args) {
  8. Scanner console = new Scanner(System.in);
  9.  
  10. int a = Integer.parseInt(console.nextLine());
  11. if (a < 0 || a > 100) {
  12. System.out.print("invalid number");
  13. } else if (a == 1) {
  14. System.out.print("one");
  15. } else if (a ==2) {
  16. System.out.print("two");
  17. } else if (a == 0) {
  18. System.out.print("zero");
  19. } else if (a==10) {
  20. System.out.print("ten");
  21. } else if (a==100) {
  22. System.out.print("one hundred");
  23. } else if (a == 11) {
  24. System.out.print("eleven");
  25. } else if (a == 12) {
  26. System.out.print("twelve");
  27. } else if (a == 13) {
  28. System.out.print("thirteen");
  29. } else if (a == 14) {
  30. System.out.print("fourteen");
  31. } else if (a == 15) {
  32. System.out.print("fifteen");
  33. } else if (a == 16) {
  34. System.out.print("sixteen");
  35. } else if (a == 17) {
  36. System.out.print("seventeen");
  37. } else if (a == 18) {
  38. System.out.print("eighteen");
  39. } else if (a == 19) {
  40. System.out.print("nineteen");
  41. } else if (a >= 20) {
  42. int tens = a/10;
  43.  
  44. if (tens ==2) {
  45. System.out.print("twenty");
  46. } else if (tens == 3) {
  47. System.out.print("thirty");
  48. } else if (tens == 4) {
  49. System.out.print("fourty");
  50. } else if (tens == 5) {
  51. System.out.print("fifty");
  52. } else if (tens == 6) {
  53. System.out.print("sixty");
  54. } else if (tens == 7) {
  55. System.out.print("seventy");
  56. } else if (tens == 8) {
  57. System.out.print("eighty");
  58. } else {
  59. System.out.print("ninety");
  60. }
  61. a %= 10;
  62. if (a == 1) {
  63. System.out.print(" one");
  64. } else if (a ==2) {
  65. System.out.print(" two");
  66. } else if (a == 3) {
  67. System.out.print(" three");
  68. } else if (a == 4) {
  69. System.out.print(" four");
  70. } else if (a == 5) {
  71. System.out.print(" five");
  72. } else if (a == 6) {
  73. System.out.print(" six");
  74. } else if (a == 7) {
  75. System.out.print(" seven");
  76. } else if (a == 8) {
  77. System.out.print(" eight");
  78. } else if (a==9){
  79. System.out.print(" nine");
  80. }
  81. }
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88. }
  89.  
  90.  
  91.  
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement