#ifndef BANKACCOUNT_H
#define BANKACCOUNT_H
class Bankaccount
{
private:
float balance;
float intRate;
float interestGot;
int transactionNum;
public:
Bankaccount(float,float); //constructor
void makeDeposit();
void withdraw();
void calcInterest(void);
float getBalance(void)
{
return balance;
}
float getInterst(void)
{
return interestGot;
}
int getTransactions(void)
{
return transactionNum;
}
};
#endif
#include"bankaccount.h"
Bankaccount::Bankaccount(float x=0, float y=0.045)
{
balance=x;
intRate=y;
interestGot=0;
transactionNum=0;
}
void Bankaccount::makeDeposit()
{
float amount;
cout<<"\t\t Enter amount:$";
cin>>amount;
balance+=amount;
transactionNum++;
cout<<"\t\t Amount is Added"< void Bankaccount::withdraw()
{
float amountOut;
if (balance==0)
{
cout<<"\t\t Sorry! you can not withdraw money.you have no balance left."< else
{
cout<<"\t\t You have:$"<< balance< cin>>amountOut;
if (amountOut>balance)
{
cout<<"\t\t Invalid Input for Withdrawing."< else
{
balance-=amountOut;
transactionNum++;
}
cout<<"\t\t You have:$"<< balance<<" left"< }
void Bankaccount:: calcInterest(void)
{
interestGot=balance*intRate;
balance+=interestGot;
}
#include"bankaccount.h"
//function prototype
void displayMenu();
int main()
{ //Declare a bankaccount object name in savingInfo
Bankaccount savingInfo(0,0);
int num;
char letter;
do
{
displayMenu();
cout<<"\t\t Enter the choice:";
cin>>num;
cout< {
switch (num)
{
case 1 :cout<<"\t\t Your balance is: $";
cout< case 4 :savingInfo.withdraw();
break;
case 5 :savingInfo.calcInterest();
cout<<"\t\t Interest is added."< }
}
else
{
cout<<"\t\t invalid input for your choice.you pick "< cout<<"\t\t Do you wants to continous or try again?(y/n)";
cin>>letter;
cout< return 0;
}
void displayMenu()
{
cout<<"\t\t 1:Display Account Ballance\n";
cout<<"\t\t 2:Display Total Interest have Received\n";
cout<<"\t\t 3:Make a Deposit\n";
cout<<"\t\t 4:Make a Withdraw\n";
cout<<"\t\t 5:Add Current Interest\n";
}