← Back to Classes
Question 74
Money Comparisons (operator< and operator<=)
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) intgetDollars()const 3) intgetCents()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
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.