Money With Operator Plus
hardQuestion 664Build a Money class that supports the + operator. It stores whole Dollars and Cents (0-99). Requirements:
1. Constructor Money(int dollars, int cents) stores both values.
2. Overload operator + so it adds two amounts and CARRIES cents into dollars (100 cents = 1 dollar).
3. Override ToString() to return $D.CC with cents ALWAYS two digits (e.g. $5.25, $1.05).
Do NOT write a Main method.
For Money(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, so 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.