Input:
7845746
Output:
Seventy Eight Lakh Forty Five Thousand Seven Hundred and Forty Six
[js theme=”” group=”” tab=”” highlight=””]
import java.io.*;
public class Num_2_Words
{
public String convert(int n)
{
String wrd[] = {“”, “One”, “Two”, “Three”, “Four”, “Five”, “Six”, “Seven”, “Eight”, “Nine”, “Ten”, “Eleven”, “Twelve”, “Thirteen”, “Fourteen”, “Fifteen”, “Sixteen”, “Seventeen”, “Eighteen”, “Nineteen”, “Twenty”, “Thirty”, “Forty”, “Fifty”, “Sixty”, “Seventy”, “Eighty”, “Ninety”};
if(n>=0&&n<=19)
return wrd[n];
if(n%10==0)
return wrd[18+n/10];
return wrd[18+n/10]+' '+wrd[n%10];
}
void ext_form(long n)
{
if(n==0)
{
System.out.println("Zero");
return;
}
String x = ""+n, h="", s2="", w="";
String nm[] = {"Hundred", "Thousand", "Lakh", "Crore", "Arab", "Kharab", "Neel", "Padm"};
int len = x.length(), l2=len, d, i;
if(len>=3)
{
h = x.substring(len-3);
x = x.substring(0,len-3);
if(x.length()%2!=0)
x = 0+x;
len = x.length();
d = len/2;
for(i=0;i
Write a program to input a number and print it in words
Programming