I'm trying to convert an amount from numbers to string. While converting 3070
to three thousand seventy only
I noticed a flaw in the code, the output is supposed to be three thousand seventy only
but instead of this the output is Three Thousand Rupees only
.
I got the code from the internet,
When i debug the code, I see the following lines
if ((rupees / 1000) > 0)
{
res = rupees / 1000;
rupees = rupees % 1000;
result = result + ' ' + rupeestowords(res) + " Thousand";
}
The problem arises in this code because 1010,1020,.....,3070,3080,3090,4010,4020.etc
all the numbers are % to 1000, that means if I enter these number the output will be wrong,
I am unable to get the proper logic here. I think i need to validate the rupees again inside another if condition.
Code below X Thousands
if ((rupees / 100) > 0)
{
res = rupees / 100;
rupees = rupees % 100;
result = result + ' ' + rupeestowords(res) + " Hundred";
}
if ((rupees % 10) > 0)
{
res = rupees % 100;
result = result + " " + rupeestowords(res);
}
result = result + ' ' + " Rupees only";
return result;
}