Money Comparisons (operator< and operator<=)
mediumQuestion 74You 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, so print one after the last line.
Hints4 available
Sign in to use hintsTopics
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.