Please add comments for each step and please seperate the code with .h and .cpp
ID: 3803442 • Letter: P
Question
Please add comments for each step and please seperate the code with .h and .cpp extension. So in total there should be 3 .h files and 4 .cpp files. In C++ please. Would appreciate this a lot!
Define the class bankAccount to store a bank customer’s account number and balance. Suppose that account number is of type int, and balance is of type double. Your class should, at least, provide the following operations: set the account number, retrieve the account number, retrieve the balance, deposit and withdraw money, and print account information. Add appropriate constructors.
Every bank offers a checking account. Derive the class checkingAccount from the class bankAccount (designed in part (a)). This class inherits members to store the account number and the balance from the base class. A customer with a checking account typically receives interest, maintains a minimum balance, and pays service charges if the balance falls below the minimum balance. Add member variables to store this additional information. In addition to the operations inherited from the base class, this class should provide the following operations: set interest rate, retrieve interest rate, set minimum balance, retrieve minimum balance, set service charges, retrieve service charges, post interest, verify if the balance is less than the minimum balance, write a check, withdraw (override the method of the base class), and print account information. Add appropriate constructors.
Every bank offers a savings account. Derive the class savingsAccount from the class bankAccount (designed in part (a)). This class inherits members to store the account number and the balance from the base class. A customer with a savings account typically receives interest, makes deposits, and withdraws money. In addition to the operations inherited from the base class, this class should provide the following operations: set interest rate, retrieve interest rate, post interest, withdraw (override the method of the base class), and print account information. Add appropriate constructors.
Write a program to test your classes designed in parts (b) and (c).
Explanation / Answer
// File: CheckingAccount .cpp
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include"BankAccount.h"
using namespace std;
class CheckingAccount :BankAccount
{
private:
double interest_rate;
double minimum_balance;
double service_charges;
public:
CheckingAccount(int acc, double bal);
~CheckingAccount();
void setInterestRate(double int_rate);
void setMinBalance(double min_bal);
void setServiceCharges(double ser_charges);
double getInterestRate();
double getMinBalance();
double getSerCharges();
};
#include"CheckingAccount.h"
CheckingAccount::CheckingAccount(int acc, double bal) :BankAccount(acc, bal)
{
}
void CheckingAccount::setInterestRate(double int_rate)
{
interest_rate = int_rate;
}
void CheckingAccount::setMinBalance(double min_bal)
{
minimum_balance = min_bal;
}
void CheckingAccount::setServiceCharges(double ser_charges)
{
service_charges = ser_charges;
}
double CheckingAccount::getInterestRate()
{
return interest_rate;
}
double CheckingAccount::getMinBalance()
{
return minimum_balance;
}
double CheckingAccount::getSerCharges()
{
return service_charges;
}
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include"BankAccount.h"
using namespace std;
class SavingAccount:BankAccount
{
private:
double interest_earned;
double interest_rate;
double depost;
double m_withdraw;
public:
SavingAccount(int acc, double bal, double int_rate);
~SavingAccount();
void setInterestRate(double int_rate);
double getInterestRate();
double withdraw(double withdraw_bal);
double postInterest();
void printAccount();
};
#include"SavingAccount.h"
SavingAccount::SavingAccount(int acc, double bal, double int_rate) :BankAccount(acc, bal)
{
interest_rate = int_rate;
}
void SavingAccount::setInterestRate(double int_rate)
{
interest_rate = int_rate;
}
double SavingAccount::getInterestRate()
{
return interest_rate;
}
double SavingAccount::withdraw(double withdraw_bal)
{
balance = balance - withdraw_bal;
return balance;
}
double SavingAccount::postInterest()
{
return (balance*interest_rate / 100);
}
void SavingAccount::printAccount()
{
cout << "Account Number: " << acc_number << endl;
cout << "Balance Amount: " << balance << endl;
cout << "Interest Earned: " << interest_earned << endl;
}
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
using namespace std;
class BankAccount
{
protected:
int acc_number;
double balance;
public:
BankAccount(int acc_num, double l_deposit);
~BankAccount();
void setAccountNumber(int accc_num);
int getAccountNumber();
double getBalance();
void deposit(double deposit_bal);
void withdraw(double withdraw_bal);
void printAccountInfo();
};
#ifndef BANKACCOUNT
#define BANKACCOUNT
#include "BankAccount.h"
#endif
BankAccount::BankAccount(int acc_num, double l_deposit)
{
acc_number = acc_num;
balance = l_deposit;
}
BankAccount::~BankAccount()
{
acc_number = 0;
balance = 0;
}
void BankAccount::setAccountNumber(int accc_num)
{
acc_number = accc_num;
}
int BankAccount::getAccountNumber()
{
return acc_number;
}
double BankAccount::getBalance()
{
return balance;
}
void BankAccount::deposit(double deposit_bal)
{
balance = balance + deposit_bal;
}
void BankAccount::withdraw(double withdraw_bal)
{
balance = balance - withdraw_bal;
}
void BankAccount::printAccountInfo()
{
cout << "Account Number: " << acc_number<<endl;
cout << "Balance Amount: " << balance << endl;
}
#include "BankAccount.h"
int main()
{
BankAccount *bank = new BankAccount(123456, 10000);
bank->printAccountInfo();
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.