← Back to Polymorphism
Question 664
Money With Operator Plus
Money With Operator Plus
Build aMoneyclass that supports the+operator. It stores wholeDollarsandCents(0-99). Requirements: 1. ConstructorMoney(int dollars, int cents)stores both values. 2. Overloadoperator +so it adds two amounts and CARRIES cents into dollars (100 cents = 1 dollar). 3. OverrideToString()to return$D.CCwith cents ALWAYS two digits (e.g.$5.25,$1.05). Do NOT write aMainmethod. ForMoney(3, 75) + Money(1, 50)the program prints the output shown in Expected Output.
Expected Output:
$5.25= newline. The output ends with a newline — print one after the last line.
Hints4 available
Sign in to use hintsTopics:
Polymorphism
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (cw, cr, fori)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.