Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import com.sun.source.tree.IfTree;
- import java.util.Locale;
- import java.util.Scanner;
- public class Homework10 {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int input = scanner.nextInt();
- String hundredS = "";
- String tens = "";
- String digits = "";
- String smallerS = "";
- int hundred = input / 100;
- int ten = (input / 10) % 10;
- int digit = input % 10;
- int small = input % 100;
- if (input > 99 & input < 200) {
- hundredS += "One hundred";
- } else if (input > 199 & input < 300) {
- hundredS += "Two hundred";
- } else if (input > 299 & input < 400) {
- hundredS += "Three hundred";
- } else if (input > 399 & input < 500) {
- hundredS += "Four hundred";
- } else if (input > 499 & input < 600) {
- hundredS += "Five hundred";
- } else if (input > 599 & input < 700) {
- hundredS += "Six hundred";
- } else if (input > 699 & input < 800) {
- hundredS += "Seven hundred";
- } else if (input > 799 & input < 900) {
- hundredS += "Eight hundred";
- } else if (input > 899 & input < 1000) {
- hundredS += "Nine hundred";
- }
- switch (ten) {
- case (2):
- tens += "Twenty";
- break;
- case (3):
- tens += "Thirty";
- break;
- case (4):
- tens += "Forty";
- break;
- case (5):
- tens += "Fifty";
- break;
- case (6):
- tens += "Sixty";
- break;
- case (7):
- tens += "Seventy";
- break;
- case (8):
- tens += "Eighty";
- break;
- case (9):
- tens += "Ninety";
- break;
- }
- switch (digit) {
- case (0):
- digits += "Zero";
- break;
- case (1):
- digits += "One";
- break;
- case (2):
- digits += "Two";
- break;
- case (3):
- digits += "Three";
- break;
- case (4):
- digits += "Four";
- break;
- case (5):
- digits += "Five";
- break;
- case (6):
- digits += "Six";
- break;
- case (7):
- digits += "Seven";
- break;
- case (8):
- digits += "Eight";
- break;
- case (9):
- digits += "Nine";
- break;
- }
- switch (small) {
- case (10):
- smallerS += "Ten";
- break;
- case (11):
- smallerS += "Eleven";
- break;
- case (12):
- smallerS += "Twelve";
- break;
- case (13):
- smallerS += "Thirteen";
- break;
- case (14):
- smallerS += "Fourteen";
- break;
- case (15):
- smallerS += "Fifteen";
- break;
- case (16):
- smallerS += "Sixteen";
- break;
- case (17):
- smallerS += "Seventeen";
- break;
- case (18):
- smallerS += "Eighteen";
- break;
- case (19):
- smallerS += "Nineteen";
- break;
- }
- if (hundred == 0 & ten == 0 & ten != 1) {
- System.out.println(digits);
- } else if (hundred == 0 & ten == 1) {
- System.out.println(smallerS);
- } else if (hundred == 0 & ten != 0) {
- System.out.println(tens + " " + digits.toLowerCase());
- } else if (hundred != 0 & ten == 0 & digit != 0) {
- System.out.println(hundredS + " and " + digits.toLowerCase());
- } else if (hundred != 0 & ten == 0 & digit == 0) {
- System.out.println(hundredS);
- } else if (hundred != 0 & ten != 0 & ten != 1 & digit != 0) {
- System.out.println(hundredS + " " + "and " + tens.toLowerCase() + " " + digits.toLowerCase());
- } else if (hundred != 0 & ten == 1 & digit == 0) {
- System.out.println(hundredS + " " + "and " + smallerS.toLowerCase());
- } else if (hundred != 0 & ten == 1) {
- System.out.println(hundredS + " " + "and " + smallerS.toLowerCase());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement