Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class e16_Number1_100ToText {
- public static void main(String[] args) {
- Scanner console = new Scanner(System.in);
- int number = Integer.parseInt(console.nextLine());
- int firstDigit = number / 10;
- int seconDigit = number % 10;
- if (number <= 10 && number >=0) {
- if (number == 0) {
- System.out.println("zero");
- } else if (number == 1) {
- System.out.println("one");
- } else if (number == 2) {
- System.out.println("two");
- } else if (number == 3) {
- System.out.println("three");
- } else if (number == 4) {
- System.out.println("four");
- } else if (number == 5) {
- System.out.println("five");
- } else if (number == 6) {
- System.out.println("six");
- } else if (number == 7) {
- System.out.println("seven");
- } else if (number == 8) {
- System.out.println("eight");
- } else if (number == 9) {
- System.out.println("nine");
- } else if (number == 10) {
- System.out.println("ten");
- }
- } else if (number < 20 && number >10) {
- if (seconDigit == 1) {
- System.out.println("eleven");
- } else if (seconDigit == 2) {
- System.out.println("twelve");
- } else if (seconDigit == 3) {
- System.out.println("thirteen");
- } else if (seconDigit == 4) {
- System.out.println("fourteen");
- } else if (seconDigit == 5) {
- System.out.println("fifteen");
- } else if (seconDigit == 6) {
- System.out.println("sixteen");
- } else if (seconDigit == 7) {
- System.out.println("seventeen");
- } else if (seconDigit == 8) {
- System.out.println("eighteen");
- } else if (seconDigit == 9) {
- System.out.println("nineteen");
- }
- } else if (number < 100 && number >=20) {
- if (firstDigit == 2) {
- System.out.print("twenty");
- } else if (firstDigit == 3) {
- System.out.print("thirty");
- } else if (firstDigit == 4) {
- System.out.print("forty");
- } else if (firstDigit == 5) {
- System.out.print("fifty");
- } else if (firstDigit == 6) {
- System.out.print("sixty");
- } else if (firstDigit == 7) {
- System.out.print("seventy");
- } else if (firstDigit == 8) {
- System.out.print("eighty");
- } else if (firstDigit == 9) {
- System.out.print("ninety");
- }
- if (seconDigit == 1) {
- System.out.println(" one");
- } else if (seconDigit == 2) {
- System.out.println(" two");
- } else if (seconDigit == 3) {
- System.out.println(" three");
- } else if (seconDigit == 4) {
- System.out.println(" four");
- } else if (seconDigit == 5) {
- System.out.println(" five");
- } else if (seconDigit == 6) {
- System.out.println(" six");
- } else if (seconDigit == 7) {
- System.out.println(" seven");
- } else if (seconDigit == 8) {
- System.out.println(" eight");
- } else if (seconDigit == 9) {
- System.out.println(" nine");
- }
- } else if (number == 100) {
- System.out.println("one hundred");
- } else System.out.println("invalid number");
- }
- }
Add Comment
Please, Sign In to add comment