Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This Program does not implement interest class Account { public: Customer * customer; float balance; int account _ number; std::vector transaction; void add _ interest

This Program does not implement interest
class Account {
public:
Customer* customer;
float balance;
int account_number;
std::vector transaction;
void add_interest();
Account(Customer* c, double balance, int num)
: customer(c), balance(balance), account_number(num){}
int get_account_number() const {
return account_number;
}
double get_balance() const {
return balance;
}
// Member functions definitions
virtual void deposit(double amount, Date date)=0;
virtual void withdraw(double amount, Date date)=0;
virtual std::string to_string() const {
return "Account : "+ std::to_string(account_number)+"
"+
customer->get_name()+", balance: $"+ std::to_string(balance);
}
Customer* get_customer() const {
return customer;
}
};
class Savings_Account : public Account {
public:
Savings_Account(Customer* cust, double bal, int accNum) : Account(cust, bal, accNum){}
void deposit(double amount, Date date) override {
balance += amount;
transaction.push_back(new Transaction("DEP", amount, balance, date));
}
void withdraw(double amount, Date date) override {
if (balance - amount >=0){
balance -= amount;
transaction.push_back(new Transaction("WD", amount, balance, date));
} else {
std::cout << "Insufficient funds for withdrawal. Charging overdraft penalty." << std::endl;
balance -= Senior::OVERDRAFT_PENALTY; //OVERDRAFT PENALTY IS SAME FOR ALL ACCOUNTS
transaction.push_back(new Transaction("ODP", Senior::OVERDRAFT_PENALTY, balance, date));
}
}
void add_interest(){
double annual_interest_rate = get_annual_interest_rate();
double interest = balance * annual_interest_rate;
deposit(interest, Date(0,0,0)); // Assuming the interest is added on the current date
transaction.push_back(new Transaction("INT CR", interest, balance, Date(0,0,0)));
}
void check_charge(double amount) const {
double charge = amount * Student::CHECK_CHARGE;
std::cout << "Check charge: $"<< std::fixed << std::setprecision(2)<< charge << std::endl;
}
double get_annual_interest_rate() const {
if (dynamic_cast(customer)){
return Student::SAVINGS_INTEREST;
} else if (dynamic_cast(customer)){
return Senior::SAVINGS_INTEREST;
} else if (dynamic_cast(customer)){
return Adult::SAVINGS_INTEREST;
}
}
};
class Checking_Account : public Account {
public:
Checking_Account(Customer* cust, double bal, int accNum) : Account(cust, bal, accNum){}
void deposit(double amount, Date date) override {
balance += amount;
transaction.push_back(new Transaction("DEP", amount, balance, date));
}
void withdraw(double amount, Date date) override {
if (balance - amount >=0){
balance -= amount;
transaction.push_back(new Transaction("WD", amount, balance, date));
} else {
std::cout << "Insufficient funds for withdrawal. Charging overdraft penalty." << std::endl;
balance -= Senior::OVERDRAFT_PENALTY; // Assuming Senior overdraft penalty for any customer type in checking
transaction.push_back(new Transaction("ODP", Senior::OVERDRAFT_PENALTY, balance, date));
}
}
void add_interest(){
double annual_interest_rate = get_annual_interest_rate();
double interest = balance * annual_interest_rate;
deposit(interest, Date(0,0,0)); // Assuming the interest is added on the current date
transaction.push_back(new Transaction("INT CR", interest, balance, Date(0,0,0)));
}
void check_charge(double amount) const {
double charge = amount * Student::CHECK_CHARGE;
std::cout << "Check charge: $"<< std::fixed << std::setprecision(2)<< charge << std::endl;
}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems For Advanced Applications 27th International Conference Dasfaa 2022 Virtual Event April 11 14 2022 Proceedings Part 2 Lncs 13246

Authors: Arnab Bhattacharya ,Janice Lee Mong Li ,Divyakant Agrawal ,P. Krishna Reddy ,Mukesh Mohania ,Anirban Mondal ,Vikram Goyal ,Rage Uday Kiran

1st Edition

3031001257, 978-3031001253

More Books

Students also viewed these Databases questions

Question

Find y'. y= |x + X (x) (x) X 1 02x+ 2x 1 O 2x + 1/3 Ex 2x +

Answered: 1 week ago