Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- /**
- * Created by ValioHP on 16.1.2017 г..
- */
- public class num {
- public static void main(String[] args) {
- Scanner console = new Scanner(System.in);
- int a = Integer.parseInt(console.nextLine());
- if (a < 0 || a > 100) {
- System.out.print("invalid number");
- } else if (a == 1) {
- System.out.print("one");
- } else if (a ==2) {
- System.out.print("two");
- } else if (a == 0) {
- System.out.print("zero");
- } else if (a==10) {
- System.out.print("ten");
- } else if (a==100) {
- System.out.print("one hundred");
- } else if (a == 11) {
- System.out.print("eleven");
- } else if (a == 12) {
- System.out.print("twelve");
- } else if (a == 13) {
- System.out.print("thirteen");
- } else if (a == 14) {
- System.out.print("fourteen");
- } else if (a == 15) {
- System.out.print("fifteen");
- } else if (a == 16) {
- System.out.print("sixteen");
- } else if (a == 17) {
- System.out.print("seventeen");
- } else if (a == 18) {
- System.out.print("eighteen");
- } else if (a == 19) {
- System.out.print("nineteen");
- } else if (a >= 20) {
- int tens = a/10;
- if (tens ==2) {
- System.out.print("twenty");
- } else if (tens == 3) {
- System.out.print("thirty");
- } else if (tens == 4) {
- System.out.print("fourty");
- } else if (tens == 5) {
- System.out.print("fifty");
- } else if (tens == 6) {
- System.out.print("sixty");
- } else if (tens == 7) {
- System.out.print("seventy");
- } else if (tens == 8) {
- System.out.print("eighty");
- } else {
- System.out.print("ninety");
- }
- a %= 10;
- if (a == 1) {
- System.out.print(" one");
- } else if (a ==2) {
- System.out.print(" two");
- } else if (a == 3) {
- System.out.print(" three");
- } else if (a == 4) {
- System.out.print(" four");
- } else if (a == 5) {
- System.out.print(" five");
- } else if (a == 6) {
- System.out.print(" six");
- } else if (a == 7) {
- System.out.print(" seven");
- } else if (a == 8) {
- System.out.print(" eight");
- } else if (a==9){
- System.out.print(" nine");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement