Answered step by step
Verified Expert Solution
Question
1 Approved Answer
C++ homework, please leave comments using // Question is in the picture below: The Assignment: Define a class named Money that stores a monetary amount.
C++ homework, please leave comments using //
Question is in the picture below:
The Assignment: Define a class named Money that stores a monetary amount. The class should have two private integer variables, one to store the number of dollars and another to store the number of cents. Include a default constructor that initializes the amount to $0.00 and an overloaded parameterized constructor to initialize any non-zero amount (as demonstrated in the example program below). You must develop your solution with three separate files; money.b, money.cpp, and main.cpp. ? ? Add the following accessor member functions: : returns the private int, dollars. Should not be able to modify the data. : returns the private int,cents. Should not be able to modify the data Add the following mutator member functions: sets the private int dollars. Does not return anything : sets the private iat cents. Does not return anything Add a condition to your setcCeats) mutator that will update the dollars member if the cents input argument is 100 or larger. o For example: a function call to setceats135) would set the cents member to 35, and increase the current dollar amount by 1. setCents(235) would set the cents member to 35, and increase the current dollar amount by 2. Add another member function named geta ountw that returns the monetary amount as a single double number. Write a uain() program that tests all of your member functions with at least two different Money objects. In addition to testing your mutators, your code should be able to print the following output (or similar) using your getDallacsf) and shown in the sample console output below ), or just the getAmount() member functions as Testing Money Class: Money object1 has the amount $20.35 Money object2 has the amount $210.03
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started