-3

I'm trying to figure out / where to start in regards to this situation say for example

I enter $127.45 in to a textbox

I would expect the application to spit back

one hundred and twenty-seven dollars and forty-five cents

The word will then be placed on a document and sent to the client.

I have found this solution which seemed promising Code Golf: Number to Words which filled me with some hope, unfortunately after trying that it only spits back

one hundred and twenty seven

Would someone be able to give me a hand?

Community
  • 1
  • 1
Code Ratchet
  • 5,758
  • 18
  • 77
  • 141

1 Answers1

0

First you need to get the decimal part of the number into a separate integer, then just call your number to words function twice something like this:

double value = 125.23;
int dollars = (int)value;
int cents = (int)((value - (int)value) * 100);
Console.WriteLine("{0} dollars and {1} cents", wordify(dollars), wordify(cents));
Martin Brown
  • 24,692
  • 14
  • 77
  • 122