package javaapplication81;
import java.util.Scanner;
/**
*
* @author admin
*/
public class JavaApplication81 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
String num[]={"one","two","three"," four","five","six","seven"," eight","nine"};
// TODO code application logic here
String num1[]={"ten","eleven"," twelve","thirteen","fourteen", "fifeteen","sixteen"," seventeen","eighteen"," nineteen"};
String num3[]={"ten","twenty"," thirty","forty","fifty"," sixty","seventy","eighty"," ninety"};
// TODO code application logic here
int n; n=sc.nextInt();
int q,r,c=0,a;a=n;int t,t1,h,h1,i,j,ten,ten1;
while(n!=0)
{
q=n/10;
r=n%10;
n=q;
c++;
}
System.out.println(c);
if(c==4)
{
t=a/1000;
t1=a%1000;
h=t1/100;
h1=t1%100;
ten=h1/10;
ten1=h1%10;
for(i=1;i<=9;i++)
{
if(t==i)
{
System.out.print(num[i-1]+" thousand ");
}
}
for(i=1;i<=9;i++)
{
if(h==i)
{
System.out.print(num[i-1]+" hundred ");
}
}
if(ten==1)
{
j=0;
for(i=11;i<=19;i++)
{
if(h1==i)
{
System.out.print(num1[j]);
}
j++;
}
}
else
{
for(i=1;i<=9;i++)
{
if(ten==i)
{
System.out.print(num3[i-1]+" ");
}
}
for(i=1;i<=9;i++)
{
if(ten1==i)
{
System.out.print(num[i-1]);
}
}
}
}
if(c==3)
{
h=a/100;
h1=a%100;
ten=h1/10;
ten1=h1%10;
for(i=1;i<=9;i++)
{
if(h==i)
{
System.out.print(num[i-1]+" hundred ");
}
}
if(ten==1)
{
j=0;
for(i=10;i<=19;i++)
{
if(h1==i)
{
System.out.print(num1[j]);
}
j++;
}
}
else
{
for(i=1;i<=9;i++)
{
if(ten==i)
{
System.out.print(num3[i-1]+" ");
}
}
for(i=1;i<=9;i++)
{
if(ten1==i)
{
System.out.print(num[i-1]);
}
}
}
}
if(c==2)
{
h1=a%100;
ten=a/10;
ten1=a%10;j=0;
for( i=11;i<=19;i++)
{
if(h1==i)
{
System.out.print(num1[j]); System.exit(0);
}j++;
}
for(i=1;i<=9;i++)
{
if(ten==i)
{
System.out.print(num3[i-1]+" ");
}}
for(i=1;i<=9;i++)
{
if(ten1==i)
{
System.out.print(num[i-1]);
}
}
}
if(c==1)
{
for(i=1;i<=9;i++)
{
if(a==i)
{
System.out.print(num[i-1]);
}
}
}
}}
No comments:
Post a Comment