Skip to content

Commit de75010

Browse files
authored
Merge pull request #17 from sengarsameer/patch-2
Added comments to NumberToWords.java #1
2 parents 9a71ec3 + 6c5f454 commit de75010

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Diff for: NumberToWords.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ public static void main(String[] args)throws IOException
1111
String l19[]={"","One ","Two ","Three ","Four ","Five ","Six ","Seven ","Eight ","Nine ","Ten ","Eleven ","Twelve ","Thirteen ","Fourteen ","Fifteen ","Sixteen ","Seventeen ","Eighteen ","Nineteen "};
1212
String l90[]={"","","Twenty ","Thirty ","Forty ","Fifty ","Sixty ","Seventy ","Eighty ","Ninety "};
1313
//System.out.println("Enter input:");
14-
t=Integer.parseInt(in.readLine());
14+
t=Integer.parseInt(in.readLine()); //taking number as input
1515
while(t>0)
1616
{ans="";int c=12;
1717
s=in.readLine();l=s.length();int n[]=new int[13];
1818
for(int i=l-1;i>=0;i--,c--)
1919
{
20-
n[c]=s.charAt(i)-48;//extracting character
20+
n[c]=s.charAt(i)-48;//extracting character and converting character to integer
2121
}y=0;
2222
for(int i=++c;i<13;i++)
2323
{
@@ -41,7 +41,7 @@ public static void main(String[] args)throws IOException
4141
if(i-1==5&&y!=0){ans=ans+"Million ";y=0;}
4242
if(i-1==8&&y!=0){ans=ans+"Thousand ";y=0;}
4343
}
44-
System.out.println(ans.trim());
44+
System.out.println(ans.trim()); //output word for coresponding place value of each digit in the number
4545
t--;
4646
}
4747
}

0 commit comments

Comments
 (0)