import java.util.*;
public class Convert
{
Scanner in()
{ return new Scanner(System.in); }
void out(String m)
{ System.out.print(m); }
long readLong(String m)
{
out(m);
return in().nextLong();
}
int readInt(String m)
{
out(m);
return in().nextInt();
}
String readString(String m)
{
out(m);
return in().nextLine();
}
String digitOne(int n)
{
String st="";
switch(n)
{
case 1:
st="One";
case 2:
st="Two";
case 3:
st="Three";
case 4:
st="Four";
case 5:
st="Five";
case 6:
st="Six";
case 7:
st="Seven";
case 8:
st="Eigth";
case 9:
st="Nine";
case 10:
st="Ten";
case 11:
st="Eleven";
case 12:
st="Twelve";
case 13:
st="Thirteen";
case 14:
st="Fourteen";
case 15:
st="Fifteen";
case 16:
st="Sixteen";
case 17:
st="Seventeen";
case 18:
st="Eighteen";
case 19:
st="Nineteen";
}
return st;
}
String digitTwo(int n)
{
String st="";
switch(n)
{
case 2:
st="Twenty";
case 3:
st="Thirty";
case 4:
st="Forty";
case 5:
st="Fifty";
case 6:
st="Sixty";
case 7:
st="Seventy";
case 8:
st="Eighty";
case 9:
st="Ninety";
}
return st;
}
String digitThree(int n)
{
String st="";
if (n==0)
st="";
else
st=digitOne(n)+"Hundred";
return st;
}
String digitFour(int n)
{
String st="";
if (n==0)
st="";
else
st=digitOne(n)+"Thousand";
return st;
}
String digitFive(int n)
{
String st="";
if (n<20)
st=digitOne(n)+digitFour(n);
else
st=digitTwo(n)+digitFour(n);
return st;
}
String digitSix(int n)
{
String st="";
st=digitThree(n)+digitFour(n);
return st;
}
String digitSeven(int n)
{
String st="";
st=digitOne(n)+"Million";
return st;
}
public Convert()
{
int n=readInt("Enter your value: ");
String result="";
if(n<20)
result=digitOne(n);
else if (n<100)
result=digitTwo(n);
out("Result: "+ result+"\n");
}
public static void main (String[] args)
{ new Convert(); }
}
I want to convert string when i input the number.