Question: Create a Money class that contains two integer attributes: dollars and cents. The class should have constructor methods to create a Money object and the

Create a Money class that contains two integer attributes: dollars and cents.

The class should have constructor methods to create a Money object and the following methods:

Constructor to create a money object Set - change the dollar and cent value of the money object AddDollars adds dollars to a money object AddDolCents Adds both dollars and cents to the object note if over 100 cents in a moneyobject, add 1 to dollars. SubtractDollars subtracts dollars from a money object. (Dollars cannot go below 0) SubtractDolCent subtracts an amount from dollars and an amount from cents, again subtract from dollars if more than 100 cents Print prints the current dollar and cent amount in the form $XXX.XX Write a driver program that creates a money object with 100 dollars and 50 cents. Add 55 dollars Add 10 dollars and 75 cents Subtract 5 dollars and 200 cents Print the remaining value of the money object Set the object to a new value of 99 dollars and 25 cents Print the value of the money object

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!