Guest User

Untitled

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