CJCoding With Joseph

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:
$5.25

Expected Output:

$5.25
Topics:
Polymorphism
Code Editor
1
Tab to indent ยท Ctrl+Enter to run ยท 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.