• 0

Format the given number into an American currency format

Convert a given number into the formatted number.

Logic

  • Traverse the┬ástring in the reverse order

  • Consider the following cases :

  • Positive numbers,

  • Negative numbers,

  • Positive floating point numbers,

  • Negative floating point numbers

Solution