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

A)Define the class bankAccount to store a bank customer\'s account number and ba

ID: 3624714 • Letter: A

Question

A)Define the class bankAccount to store a bank customer's account number and balance .
Suppose that account number is of type int m and balance is of type double . Your class should at least , provide the account number m retrive the balance , deposit and withdraw money , and print account information. Add appropriate constructors.

B) Every bank offers a checking account . Drive the class checkingAccount from the class bankAccount( design in part (a).This class inherits member 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 opreation inherited from the base class , this class should provide the following opreation : set interest rate, retrieve interest ratem, 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.
c. 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 foolowing 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).By C++.

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()

{    
checkingAccount a(1234,1000);  
checkingAccount b(5678, 450);  
savingsAccount c(91011, 9300);    
savingsAccount d(121314, 32);
a.deposit(1000);  
b.deposit(2300);    
c.deposit(800);    
d.deposit(500);
a.postInterest();  
b.postInterest();
c.postInterest();  
d.postInterest();
a.print();    
b.print();  
c.print();
d.print();    
a.writeCheck(250);  
b.writeCheck(350);    
c.withdraw(120);    
d.withdraw(290);
a.print();  
b.print();  
c.print();  
d.print();  
system("pause");
return 0;
}