Ive been stuck on this problem, any help would be greatly appreciated. 1. Create
ID: 3634456 • Letter: I
Question
Ive been stuck on this problem, any help would be greatly appreciated.1. Create a money class using the following header file
// Filename: money.h
class money
{
public:
money(int d = 0, int c = 0);
void setMoney(int d, int c);
void getMoney(int & d, int & c) const;
void print() const; // in the form $1.05
int dollarsToCents() const; // converts $1.05 to 105 cents
bool equalMoney(money otherMoney) const; // checks if two money objects are equal
private:
int dollars;
int cents;
};
2. Create the corresponding implementation file, money.cpp, and include appropriate libraries
3. Create a driver program, group#.cpp that accomplishes the following:
Create object M1 and M3 using the default constructor
Create object M2 using the initialization constructor with two parameters (7 for dollars and 75 for cents)
Set object M1 to $5.05 using the setMoney function
Have the user enter the dollars and cents for M3 and then set the data members of M3 to these user entered values
Display the values for M1, M2, and M3 using the print function
Display the dollars value and the cents value for M1 using the getMoney function – do not use print function
Use the dollarsToCents function to convert M2 to cents and display the resulting cents
Check to see if M2 and M3 are equal using the equalMoney function. Display a message stating either - M2 and M3 are equal or M2 and M3 are not equal.
Be sure that the output of the driver program is documented, easy to read, and easy to understand. The following is an example of what you should display….
M1 should be $5.05
After testing the setMoney function … M1 is $5.05
M2 should be $7.75
After testing the initialization constructor … M2 is $7.75
Etc…
Explanation / Answer
Dear User, //Class Money declartion #ifndef MONEY_H; #define MONEY_H; class Money { public: money(int d = 0, int c = 0); void setMoney(int d, int c); void getMoney(int & d, int & c) const; void print() const; int dollarsToCents() const; bool equalMoney(money otherMoney) const; private: int dollars; int cents; }; #endif; ---------------------------------------------------------------------------------------------------------- #include #include"Money.h"; #include Money::Money(int d. int c) { setMoney(d.c); } void Money::setMoney(int d, int c) { dollars = d; cents= c; } void Money::getMoney(int &d, int &c) const { d = dollars; c=cents; } void Money::print() const { coutRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.