Write a program to convert integer into its equivalent name
import java.util.Scanner; public class IntegerToItsEqualentName { public static void main(String[] args) { Scanner sc=new Scanner(System.in); System.out.println("Enter Number"); int num=sc.nextInt(); int m=0,c=0; int a[]=new int[10]; while(num>0) { m=num%10; a[c]=m; num=num/10; c++; } for(int k=c-1;k>=0;k--) { switch (a[k]) { case 0: System.out.print("ZERO "); break; case 1: System.out.print("ONE "); break; case 2: System.out.print("TWO "); break; case 3: System.out.print("THREE "); break; case 4: System.out.print("FOUR "); break; case 5: System.out.print("FIVE "); break; case 6: System.out.print("SIX "); break; case 7: System.out.print("SEVEN "); break; case 8: System.out.print("EIGHT "); break; case 9: System.out.print("NINE "); break; default: break; } } } } OUTPUT: Enter Number 12069 ONE TWO ZERO SIX NINE
No comments:
Post a Comment