CJCoding With Joseph
15free / daySign inCreate account

Money With Operator Plus

Build 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 — print one after the last line.

Hints4 available
Topics:
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.