C++ Object-Oriented Programming - Create a class called Account with all of these requirements met. The Money class is given before the pictures for the requirements of the Account class.
Money.h =========
#ifndef Money_h #define Money_h
class Money { private: int dollars, cents; public: Money(); Money(int dol, int cen); Money(int dol); Money(double amt); int getPennies() const; bool isNegative() const; void add(const Money &m); void subtract(const Money &m); bool isEqual(const Money &m); void print() const; };
#endif /* Money_h */
Money.cpp =========
#include "Money.h" #include using namespace std; Money::Money() { dollars = 0; cents = 0; } Money::Money(int dol, int cen) { dollars = dol; cents = cen; if(dollars 0) cents = -cents; if(cents 0) dollars = -dollars; //keep the dollar and cents adjusted. Don't let cents to be be 100 or more if(cents > 100) { dollars += cents / 100; cents %= 100; } } Money::Money(int dol) { dollars = dol; cents = 0; } Money::Money(double amt) { dollars = amt; cents = (amt * 100 - dollars * 100); } int Money::getPennies() const { return dollars * 100 + cents; } bool Money::isNegative() const { if(dollars void Money::subtract(const Money &m) { int pennies = getPennies() - m.getPennies(); dollars = pennies / 100; cents = pennies % 100; } bool Money::isEqual(const Money &m) { if(getPennies() == m.getPennies()) return true; else return false; } void Money::print() const { if(isNegative()) cout
Account Class Requirements The Account class shal have 4 constructors * A default constructor that initializes your Account object with a name Savings," an interest rate * A constructor that takes a string, double, and Money object to initialize your Account's name * A constructor that takes a string, double, and an integer that represents your initial balance (a clean * A constructor that takes a string, double, and a dou of 0.00%, and an initial balance of $0.00 interest rate, and balance respectively dollar amount) ble that represents your initial balance - std::string getName) const - double getRate ) const - const Money getBalance ) const - void setName (std::string newName) - void deposit (const Money &m) - void deposit (int d, int c) - void deposit (int d) - void deposit (double d) * For all versions of the deposit function, the function shall not accept negative amounts of money * For all versions of the deposit function, the balance of the account shall be updated accordingly - const Money withdraw (const Money &m) - const Money withdraw (int d, int c) - const Money withdraw (int d) - const Money withdraw (double d) * For all versions of the withdraw function, the function shall not accept negative amounts of money * For all versions of the withdraw function, the user shall not overdraw by more than $50.00 * For all versions of the withdraw function, the balance of the account shall be updated accordingly - void accrue () The accrued interest shall be calculated and added to the balance - void print ) const * This function shall only pri nt the balance; formatting requirements are identical to that of the Money class * This function prints the amount of Money you have: it must print a "$,' and always show two decimal * Negative amounts of Money shall be represented in the following manner: ($X.Xx) aces - void transferTo (Account &dest, const Money &amount) * The function shall not transfer negative amounts of money