CJCoding With Joseph
15per day

Money Comparisons (operator< and operator<=)

You want to compare money amounts for sorting and "at most" checks.

Create a class Money that stores an amount using TWO ints: dollars and cents.
- cents should always be kept in the range 0..99 (normalize in the constructor and after operations).

Requirements:
1) Constructor Money(int dollars, int cents)
2) int getDollars() const
3) int getCents() const
4) Overload operator< and operator<= by comparing total value

Do NOT write a main function.

Expected Output:

true
false
Topics:
ClassesOperator Overloading
Code Editor
1
Tab to indent ยท Ctrl+Enter to run ยท Ctrl+Space to expand shortcuts (cout, fori)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.