Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++ Object-Oriented Programming - Create a class called Account with all of thes

ID: 3880544 • Letter: C

Question

C++ Object-Oriented Programming - Create a class called Account with all of these requirements met.

·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 double that represents your initia of 0.00%, and an initial balance of $0.00 interest rate, and balance respectively dollar amount) l 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 print 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 laces * Negative amounts of Money shall be represented in the following manner: (SX.Xx) - void transferTo (Account &dest;, const Money &amount;) * The function shall not transfer negative amounts of money

Explanation / Answer

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

/*
* File: Account.h
* Author: abhiramagopaladasa
*
* Created on January 30, 2018, 1:13 PM
*/

#ifndef ACCOUNT_H
#define ACCOUNT_H
#include "Money.h"
#include <string>


class Account {
  
public:
  
Account();
Account(std::string accountN,double interestR,Money mon);
Account(std::string accountN,double interestR, double bal);
Account(std::string accountN,double interestR, int bal);
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);
  
  
const Money withdraw(const Money &m);
const Money withdraw(int d, int c);
const Money withdraw(int d);
const Money withdraw(double d);
  
void accrue();
void print() const;
private:
std::string accountName;
Money money;
double interestRate;
  
};

#endif /* ACCOUNT_H */

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

/*
* File: Account.cpp
* Author: abhiramagopaladasa
*
* Created on January 30, 2018, 1:13 PM
*/

#include "Account.h"
#include "string"

Account::Account() {
this->accountName="Savings";
this->interestRate=0;
this->money.setMoney(0);
}

Account::Account(std::string accountN, double interestR, Money mon) {
this->accountName=accountN;
this->money=interestR;
this->money=mon;
}
Account::Account(std::string accountN, double interestR, double bal){
this->accountName=accountN;
this->money=interestR;
this->money.setMoney(bal);
}

Account::Account(std::string accountN, double interestR, int bal){
this->accountName=accountN;
this->money=interestR;
this->money.setMoney(bal);
}

void Account::deposit(const Money& m) {
double x =m.getMoney();
this->money.addMoney(x);
}
void Account::deposit(int d, int c) {
//if d is the balance
if(d>0){
this->money.addMoney(d);
}
}

const Money Account::withdraw(const Money& m) {
double x =m.getMoney();
this->money.removeMoney(x);
return this->money;
}

const Money Account::withdraw(int d, int c) {
double x =d;
this->money.removeMoney(x);
return this->money;
}

void Account::accrue() {
//details of how the interest is calc is not given. there is no details of months and others.How to calc?
}

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

/*
* File: Money.h
* Author: abhiramagopaladasa
*
* Created on January 30, 2018, 2:06 PM
*/

#ifndef MONEY_H
#define MONEY_H

class Money {
public:
Money();
Money(double m);
double getMoney(void)const;
void addMoney(const double m);
void removeMoney(const double m);
void setMoney(const double m);
virtual ~Money();
private:
double money;
};

#endif /* MONEY_H */

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

/*
* File: Money.cpp
* Author: abhiramagopaladasa
*
* Created on January 30, 2018, 2:06 PM
*/

#include "Money.h"

Money::Money() {
this->money=0;
}

Money::Money(double m) {
this->money=m;
}


Money::~Money() {
}

double Money::getMoney() const {
return this->money;
}


void Money::setMoney(double m) {
this-> money=m;
}

void Money::addMoney(double m) {
if(m>=0){
this->money+=m;
}
}

void Money::removeMoney(const double m) {
if(!(m-this->money>50) && m>0){//to make sure account is not overdrawn by more than 50$
this->money-=m;
}
}

//transferTo and print() functions could not be implemented needed another 10 mins for it.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at drjack9650@gmail.com
Chat Now And Get Quote