To convert numbers between 100 and 999 into words form.
PROGRAM :
import java.util.Scanner;
public class Conversion {
public static void main(String[] args)
{
int a,c,b,d,e;
System.out.println("this is the program for conversion of number in words");
System.out.println("enter a number between 100 and 999");
Scanner s= new Scanner (System.in);
a= s.nextInt();
c= a/100;
b= a%100;
d=b/10;
e = b%10;
if(c==1)
System.out.println("One hundred and");
if(c==2)
System.out.println("Two hundred and");
if(c==3)
System.out.println("Three hundred and");
if(c==4)
System.out.println("Four hundred and");
if(c==5)
System.out.println("Five hundred and");
if(c==6)
System.out.println("Six hundred and");
if(c==7)
System.out.println("Seven hundred and");
if(c==8)
System.out.println("Eight hundred and");
if(c==9)
System.out.println("Nine hundred and");
if(b==11)
System.out.print("Eleven");
if(b==12)
System.out.print("Twelve");
if(b==10)
System.out.print("Ten");
if(b==13)
System.out.print("Thirteen");
if(b==14)
System.out.print("Fourteen");
if(b==15)
System.out.print("Fifteen");
if(b==16)
System.out.print("Sixteen");
if(b==17)
System.out.print("Seventeen");
if(b==18)
System.out.print("Eighteen");
if(b==19)
System.out.print("Nineteen");
if(b==20 | d==2)
System.out.print("Twenty"); if(b==30 | d==3)
System.out.print("Thirty");
if(b==40 | d==4)
System.out.print("Forty");
if(b==50| d==5)
System.out.print("Fifty");
if(b==60 |d==6)
System.out.print("Sixty");
if(b==70 |d==7)
System.out.print("Seventy");
if(b==80 |d==8)
System.out.print("Eighty");
if(b==90 | d==9)
System.out.print("ninety");
else if(e==1)
System.out.print("One");
else if(e==2)
System.out.print("Two");
else if(e==3)
System.out.print("Three");
else if(e==4)
System.out.print("Four");
else if(e==5)
System.out.print("Five");
else if(e==6)
System.out.print("Six");
else if(e==7)
System.out.print("Seven");
else if(e==8)
System.out.print("Eight");
else if(e==9)
System.out.print("Nine");
}
}
No comments:
Post a Comment