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

*define the class bankaccount to store abank customer\'s account number and bala

ID: 3631352 • Letter: #

Question

*define the class bankaccount to store abank customer's account number and balance. suppose that account number is of type int , and balance is of type double .you 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 oppropriate constructors .
*every bank offers achecking account . derive the class checkingaccount from the class bankaccount .this class inherits members to store the account number and the balance from the base class . acustomer with a checking account typically receives interest , maintains aminimum 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 ACHECK , WITHDRAW (OVERRIDE THE METHOD OF THE BASE CLASS ) , AND PRINT ACCOUNT INFORMATION. ADD APPROPRITE CONSTRUCTORS.

int main()
{

int Accountnumber =1000 ;
checkingAccount JackAccount(Accountnumber++,1000);
checkingAccount LisaAccount(Accountnumber++,450);
bankAccount samirAccount(Accountnumber++,9300);
bankAccount ritaAccount(Accountnumber++,32);

JackAccount.Deposit(1000);
LisaAccount.Deposit(2300);
samirAccount.Deposit(800);
ritaAccount.Deposit(500);

JackAccount.postInterest();
LisaAccount.postInterest();

cout << "***********************************"<<endl;
JackAccount.print();
LisaAccount.print();
samirAccount.print();
ritaAccount.print();
cout << "***********************************"<<endl<<endl;

JackAccount.writcheck(250);
LisaAccount.writcheck(350);
samirAccount.writcheck(120);
ritaAccount.writcheck(290);

cout <<"******After withdrawals*********************"<<endl;
JackAccount.print();
LisaAccount.print();
samirAccount.print();
ritaAccount.print();
cout << "***********************************"<<endl<<endl;

return 0;

}

Explanation / Answer

please rate - thanks

#include <iostream>
#include <iomanip>
using namespace std;
class bankAccount
{public:
    bankAccount(int,double);   
    void setAccNum(int);
    int getAccNum();
    double getBalance();
    void withdraw(double);
    void deposit(double);
    void print();
protected:
    int accNum;
    double balance;
};
class savingsAccount: public bankAccount
{public:
    savingsAccount(int,double);
    void setRate(double);  
    double getRate();
    void withdraw(double);
    void postInterest();
    void savingsAccount::print();
protected:
    double rate;
};
class checkingAccount: public bankAccount
{
public:
    checkingAccount(int accNum,double bal);  
    double getMinBal();
    double getRate();
    double getFee();
    void setMinBal(double);   
    void setRate(double);   
    void setFee(double);
    void postInterest();
    bool checkMinBal(double);
    void checkingAccount::writeCheck(double);
    void withdraw(double);
    void print();
protected:
    double rate,minBal,fee;
};
bankAccount::bankAccount(int n,double b)
{accNum=n;
balance=b;
}
void bankAccount::setAccNum(int a)
{accNum=a;
}
int bankAccount::getAccNum()
{return accNum;
}
double bankAccount::getBalance()
{return balance;
}
void bankAccount::withdraw(double a)
{balance-=a;
}
void bankAccount::deposit(double a)
{balance+=a;
}
void bankAccount::print()
{cout<<accNum<<"Balance: $"<<setprecision(2)<<fixed<<balance<<endl;
}
checkingAccount::checkingAccount(int n,double b):bankAccount(n,b)
{setRate(.04);
setMinBal(500);
setFee(20);
}
double checkingAccount::getMinBal()
{return minBal;
}
double checkingAccount::getRate()
{return rate;
}
double checkingAccount::getFee()
{return fee;
}
void checkingAccount::setMinBal(double m)
{minBal=m;
}
void checkingAccount::setRate(double r)
{rate=r;
}
void checkingAccount::setFee(double f)
{fee=f;
}
void checkingAccount::postInterest()
{balance+=(balance*rate);
}
bool checkingAccount::checkMinBal(double a)
{if(balance-a>=minBal)
       return true;
else
       return false;
}
void checkingAccount::writeCheck(double a)
{withdraw(a);
}
void checkingAccount::withdraw(double a)
{if(balance-a<0)
     cout<<"insufficient funds for $"<<a<<" withdrawal ";
else if(balance-a<minBal)
     if(balance-a-fee<minBal)
        cout<<"insufficient funds for withdrawal + fees, since balance will be below minimum ";
     else
        {cout<<"balance below minimum. $"<<fee<<" fee charged ";
         balance-=(a+fee);
        }
else
    balance-=a;
}
void checkingAccount::print()
{cout<<"Interest Checking ACCT#: "<<getAccNum()
     <<" Balance: $"<<setprecision(2)<<fixed<<getBalance()<<endl;
}
savingsAccount::savingsAccount(int n,double b):bankAccount(n,b)
{setRate(.06);
}
double savingsAccount::getRate()
{return rate;
}
void savingsAccount::setRate(double r)
{rate=r;
}
void savingsAccount::withdraw(double a)
{if(balance-a<0)
   cout<<"insufficient funds for $"<<setprecision(2)<<fixed<<" withdrawal ";
else
balance-=a;
}
void savingsAccount::postInterest()
{balance+=(balance*rate);
}
void savingsAccount::print()
{cout<<"Savings ACCT#: "<<getAccNum()
      <<" Balance: $"<<setprecision(2)<<fixed<<getBalance()<<endl;
}
int main()

{    

int accountNumber = 1000;

checkingAccount jackAccount(accountNumber++,1000);  

checkingAccount lisaAccount(accountNumber++, 450);  

savingsAccount samirAccount(accountNumber++, 9300);    

savingsAccount ritaAccount(accountNumber++, 32);



jackAccount.deposit(1000);  

lisaAccount.deposit(2300);    

samirAccount.deposit(800);    

ritaAccount.deposit(500);



jackAccount.postInterest();  

lisaAccount.postInterest();

samirAccount.postInterest();  

ritaAccount.postInterest();



     cout << "***********************************" << endl;    

jackAccount.print();    

lisaAccount.print();  

samirAccount.print();

ritaAccount.print();    



cout << "***********************************" << endl << endl;

jackAccount.writeCheck(250);  

lisaAccount.writeCheck(350);    

samirAccount.withdraw(120);    

ritaAccount.withdraw(290);


cout << "********After withdrawals ***************" << endl;  

jackAccount.print();  

lisaAccount.print();  

samirAccount.print();  

ritaAccount.print();  

cout << "***********************************" << endl << endl;

return 0;
}