Files

2.0 KiB

Hints

General

1. Estimate value after exchange

2. Calculate currency left after an exchange

3. Calculate value of bills

4. Calculate number of bills

  • You need to divide amount into denomination.

  • To remove decimal places from a floating point value, you can use the floor() function.

  • You need an integer to get the exact number of bills. The floor function can take the desired output type as a parameter.

    Note: The ÷ operator, or div() function, also does floor division. However, if an operand is floating point the result is still floating point.

5. Calculate leftover after exchanging into bills

  • You need to find the remainder of amount that does not equal a whole denomination.
  • The Modulo operator % can help find the remainder.

6. Calculate value after exchange

  • You need to calculate spread percent of exchange_rate using multiplication operator and add it to exchange_rate to get the exchanged currency.
  • The actual rate needs to be computed. Remember to add exchange rate and exchange fee.
  • You can get exchanged money affected by commission by using a divide operation, plus type casting to integer if necessary.