C++ # # BankAccount Class Make a Bankaccount class with the following attributes
ID: 3716022 • Letter: C
Question
C++ # # BankAccount Class
Make a Bankaccount class with the following attributes and methods:
# Attributes
* name
* acct_number
* phone
* balance
* rate
# Methods
* deposit
* withdraw
* balance
# Savings class
Create an Savings class that inherits from "BankAccount" with the following attributes and actions
## Attributes
* minimum_balance
* withdraw_limit
## Actions
* when 'balance' drops below 'minimum_balance', the users gets a warning
* when 'withdraw' is greater than 'withdraw_limit', it dis-allows the withdraw.
## Checking Class
Create an Checking class that inherits from 'BankAccount' with the following attributes & actions
## Attributes
* overdraft_fee
## Actions
* When 'balance' drops below 0, the users gets an additional 'overdraft_fee' withdrawn from account
## Interface
Finally create a menu(with functions) that allow to open new bank accounts, put money in, take money out, and print totals.
********* PLEASE COMPLETE IT WITH CLASS INHERITENCE!!
Explanation / Answer
#include<iostream>
using namespace std;
class BankAccount{
public:
string name;
int account_num;
int phone;
int balance;
double rate;
static int acc_num;
BankAccount(string name,int phone,int balance,double rate)
{
static int acc_num=0;
this->account_num=++acc_num;
this->name=name;
this->phone=phone;
this->balance=balance;
this->rate=rate;
}
void deposit(int amount)
{
this->balance+=amount;
}
void withdraw(int amount)
{
this->balance-=amount;
cout<<"Successfully Withdrawn "<<amount<<endl;
}
int balance()
{
return this->balance;
}
};
class Savings:public BankAccount{
public:
int minimum_balance;
int withdraw_limit;
Savings(string name,int phone,int balance,double rate,int minimum_balance,int withdraw_limit):BankAccount(name,phone,balance,rate)
{
this->minimum_balance=minimum_balance;
this->withdraw_limit=withdraw_limit;
}
void withdraw(int amount)
{
if(amount>this->withdraw_limit)
{
cout<<"Amount greater than withdraw limit! ";
}
else
{
this->balance-=amount;
cout<<"Successfully Withdrawn "<<amount<<endl;
if(this->balance<this->minimum_balance)
{
cout<<"Balance less than minimum balance, please deposit! ";
}
}
}
};
class Checking:public BankAccount{
public:
int overdraft_fee;
Checking(string name,int phone,int balance,double rate,int overdraft_fee):BankAccount(name,phone,balance,rate){
this->overdraft_fee=overdraft_fee;
}
void withdraw(int amount)
{
this->balance-=amount;
if(this->balance<0)
{
cout<<"Overdraft fee charged! ";
this->balance-=this->overdraft_fee;
}
}
};
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.