Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class ExerciseTen {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String input = scanner.nextLine();
- int inputNumber = Integer.parseInt(input);
- int tens;
- int ones;
- if (inputNumber == 0) {
- System.out.print("Zero");
- }
- //HUNDREDS
- if (inputNumber >= 100 && inputNumber <= 999) {
- if (inputNumber < 200) {
- System.out.print("One hundred ");
- }
- if (inputNumber >= 200 && inputNumber < 300) {
- System.out.print("Two hundred ");
- }
- if (inputNumber >= 300 && inputNumber < 400) {
- System.out.print("Three hundred ");
- }
- if (inputNumber >= 400 && inputNumber < 500) {
- System.out.print("Four hundred ");
- }
- if (inputNumber >= 500 && inputNumber < 600) {
- System.out.print("Five hundred ");
- }
- if (inputNumber >= 600 && inputNumber < 700) {
- System.out.print("Six hundred ");
- }
- if (inputNumber >= 700 && inputNumber < 800) {
- System.out.print("Seven hundred ");
- }
- if (inputNumber >= 800 && inputNumber < 900) {
- System.out.print("Eight hundred ");
- }
- if (inputNumber >= 900) {
- System.out.print("Nine hundred ");
- }
- if (inputNumber % 100 != 0) {
- System.out.print("and ");
- }
- }
- tens = inputNumber % 100;
- //TENS
- if (tens == 10) {
- if (inputNumber > 99) {
- System.out.print("ten");
- } else {
- System.out.print("Ten");
- }
- }
- if (tens == 11) {
- tens -= 11;
- if (inputNumber > 99) {
- System.out.print("eleven");
- } else {
- System.out.print("Eleven");
- }
- }
- if (tens == 12) {
- tens -= 12;
- if (inputNumber > 99) {
- System.out.print("twelve");
- } else {
- System.out.print("Twelve");
- }
- }
- if (tens == 13) {
- tens -= 13;
- if (inputNumber > 99) {
- System.out.print("thirteen");
- } else {
- System.out.print("Thirteen");
- }
- }
- if (tens == 14) {
- tens -= 14;
- if (inputNumber > 99) {
- System.out.print("fourteen");
- } else {
- System.out.print("Fourteen");
- }
- }
- if (tens == 15) {
- tens -= 15;
- if (inputNumber > 99) {
- System.out.print("fifteen");
- } else {
- System.out.print("Fifteen");
- }
- }
- if (tens == 16) {
- tens -= 16;
- if (inputNumber > 99) {
- System.out.print("sixteen");
- } else {
- System.out.print("Sixteen");
- }
- }
- if (tens == 17) {
- tens -= 17;
- if (inputNumber > 99) {
- System.out.print("seventeen");
- } else {
- System.out.print("Seventeen");
- }
- }
- if (tens == 18) {
- tens -= 19;
- if (inputNumber > 99) {
- System.out.print("eighteen");
- } else {
- System.out.print("Eighteen");
- }
- }
- if (tens == 19) {
- tens -= 19;
- if (inputNumber > 99) {
- System.out.print("nineteen");
- } else {
- System.out.print("Nineteen");
- }
- }
- if (tens >= 20 && tens < 30) {
- if (inputNumber > 99) {
- System.out.print("twenty ");
- } else {
- System.out.print("Twenty ");
- }
- }
- if (tens >= 30 && tens < 40) {
- if (inputNumber > 99) {
- System.out.print("thirty ");
- } else {
- System.out.print("Thirty ");
- }
- }
- if (tens >= 40 && tens < 50) {
- if (inputNumber > 99) {
- System.out.print("forty ");
- } else {
- System.out.print("Forty ");
- }
- }
- if (tens >= 50 && tens < 60) {
- if (inputNumber > 99) {
- System.out.print("fifty ");
- } else {
- System.out.print("Fifty ");
- }
- }
- if (tens >= 60 && tens < 70) {
- if (inputNumber > 99) {
- System.out.print("sixty ");
- } else {
- System.out.print("Sixty ");
- }
- }
- if (tens >= 70 && tens < 80) {
- if (inputNumber > 99) {
- System.out.print("seventy ");
- } else {
- System.out.print("Seventy ");
- }
- }
- if (tens >= 80 && tens < 90) {
- if (inputNumber > 99) {
- System.out.print("eighty ");
- } else {
- System.out.print("Eighty ");
- }
- }
- if (tens >= 90) {
- if (inputNumber > 99) {
- System.out.print("ninety ");
- } else {
- System.out.print("Ninety ");
- }
- }
- //ONES
- ones = tens % 10;
- if (ones == 1) {
- if (inputNumber < 10) {
- System.out.print("One");
- } else {
- System.out.print("one");
- }
- }
- if (ones == 2) {
- if (inputNumber < 10) {
- System.out.print("Two");
- } else {
- System.out.print("two");
- }
- }
- if (ones == 3) {
- if (inputNumber < 10) {
- System.out.print("Three");
- } else {
- System.out.print("three");
- }
- }
- if (ones == 4) {
- if (inputNumber < 10) {
- System.out.print("Four");
- } else {
- System.out.print("four");
- }
- }
- if (ones == 5) {
- if (inputNumber < 10) {
- System.out.print("Five");
- } else {
- System.out.print("five");
- }
- }
- if (ones == 6) {
- if (inputNumber < 10) {
- System.out.print("Six");
- } else {
- System.out.print("six");
- }
- }
- if (ones == 7) {
- if (inputNumber < 10) {
- System.out.print("Seven");
- } else {
- System.out.print("seven");
- }
- }
- if (ones == 8) {
- if (inputNumber < 10) {
- System.out.print("Eight");
- } else {
- System.out.print("eight");
- }
- }
- if (ones == 9) {
- if (inputNumber < 10) {
- System.out.print("Nine");
- } else {
- System.out.print("nine");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment