a. Define the class bankAccount to store a bank customer’s account number and ba
ID: 3631805 • 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, 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.
b. 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.
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 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.
d. You need to separate the classes into their .h and .cpp files.
e. Test your classes designed in parts (b) and (c). Assume the following transactions (please add the necessary comments in the output) (DO NOT HARDCODE these inputs in your program, prompt the user for these options):
Set Account Numbers 1000, 1001, 1002, 1004 to
Create Checking Account for Jack with $1000
Create Checking Account for Lisa with $450
Create Checking Account for Samir with $9300
Create Checking Account for Rita with $32
Deposit $1000 into Jack's Checking Account
Deposit $2300 into Lisa's Checking Account
Deposit $800 into Samir's Checking Account
Deposit $500 into Rita's Checking Account
Post Interest on Jack's Checking Account
Post Interest on Lisa's Checking Account
Post Interest on Samir's Checking Account
Post Interest on Rita's Checking Account
Print Jack's Checking Account Information
Print Lisa's Checking Account Information
Print Samir's Checking Account Information
Print Rita's Checking Account Information
Jack writes a check in the amount of $250
Lisa writes a check in the amount of $350
Samir withdraws the amount of $120
Rita withdraws the amount of $290
Print Jack's Checking Account Information
Print Lisa's Checking Account Information
Print Samir's Checking Account Information
Print Rita's Checking Account Information
You cannot use any STL classes!
I would like to know how to do this program in Microsoft Visual Studio C++ 2010 and for it to run without any errors. It should also prompt the user for all the commands.
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 acct=1000;
checkingAccount Jack(acct++,1000);
checkingAccount Lisa(acct++, 450);
savingsAccount Samir(acct++, 9300);
savingsAccount Rita(acct++, 32);
Jack.deposit(1000);
Lisa.deposit(2300);
Samir.deposit(800);
Rita.deposit(500);
Jack.postInterest();
Lisa.postInterest();
Samir.postInterest();
Rita.postInterest();
Jack.print();
Lisa.print();
Samir.print();
Rita.print();
Jack.writeCheck(250);
Lisa.writeCheck(350);
Samir.withdraw(120);
Rita.withdraw(290);
Jack.print();
Lisa.print();
Samir.print();
Rita.print();
system("pause");
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.