CJCoding With Joseph
15free / daySign inCreate account

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

= newline. The output ends with a newline — print one after the last line.

Hints4 available
Topics:
ClassesOperator Overloading
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · 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.