Hi there;
Is there anybody out there knows how to design a function or data flow on how to convert a numerical currency valu (33,163.33) into words
33Million one hundred sixty three thousand point thirty three.
Thanx
First of all, wouldn't that be thrity three thousand, one hundred and sixty three point thirty three?
And to do that, you would basically need to make a function that would check how many digits were infront of the decimal point, and then based on that, determine what each number's word equivalent would be, and then do the same for after the decimal point.
it would be rather long and complex, and I'm not entirely sure on all of the details. You can take everything before the decimal by using the <cmath> function floor(double) to get an integer result.
This is what I have so far, I would suggest using a switch to determine which words to create, and I'm not sure how to isolate the decimal part of the number, but once that is done you can work with it similarly to the left part of the number.
- string convertToWords(double value)
-
{
-
int left = floor(value);
-
int temp;
-
int section = 1;
-
-
string words = “”;
-
string part;
-
-
while (left > 0)
-
{
-
temp = left % 1000;
-
left = left / 1000;
-
-
//convert temp into words of blank hundred, blankty blank
-
//store this part of the words in the string part;
-
//use int section to determine if it’s the millions, thousands, etc.
-
-
words = part + words;
-
section = section + 1;
-
}
-
}