Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 3

#ifindef BANKACCOUNT_H

#define BANKACCOUNT_H
class BankAccount
{
private:
double balance;
double interestRate;
double interest;
int transections;
public:
BankAccount (double a, double b)
{
balance=a;
interestRate=b;
}
void setInterestRate (double IR)
{
cout<<"Please enter new interest rate: ";
cin>>IR;
interestRate=IR;
}
void makedeposit (double Amount_of_deposit)
{
cout<<"How much money you wanted to deposit in your account: ";
cin>>Amount_of_deposit;
balance=balance+Amount_of_deposit;
}
void withdraw (double Amount_of_withdrawal)
{
cout<<"How much money you wanted to withdrawal from your account:
";
cin>>Amount_of_withdrawal;
if (balance>Amount_of_withdrawal)
{
balance=balance-Amount_of_withdrawal;
}
else
{
cout<<"ERROR!";
}
}
void calcInterest ()
{
interest=interestRate*balance;
balance=balance-interest;
}
double getinterestRate ()
{
return interestRate;
}
double getbalance ()
{
return balance;
}
double getinterest ()
{
return interest;
}
int gettransections (int a)
{
transections=a;
return transections;
}
};
#endif

#include<iostream>
#include "BankAccount.h"
using namespace std;
int main()
{
double Amount_of_deposit;
double Amount_of_withdrawal;
double IR;
int a;

BankAccount A1(0,0.045);
cout<<" Welcome to your Bank Account"<<endl;
cout<<"Press 1: If you wanted to makedeposit to your account "<<endl;
cout<<"Press 2: If you wanted to withdrawal amount from your account "<<endl;
cout<<"Press 3: If you wanted to get account balance "<<endl;
cout<<"Press 4: If you wanted to get interest rate "<<endl;
cout<<"Press 5: If you wanted to get interest "<<endl;
cout<<"Press 6: If you wanted to get transections you have made "<<endl;
cout<<"Press 7: If you wanted to set interest rate "<<endl;
cout<<"Press 8: To exit "<<endl;
int functions;
while (functions!=8)
{
cin>>functions;
switch (functions)
{
case 1:
{

A1.makedeposit(Amount_of_deposit);
a=a+1;
break;
}
case 2:
{

A1.withdraw(Amount_of_withdrawal);
a=a+1;
break;
}
case 3:
{
cout<<"Current balance in your account is: ";
A1.getbalance();
break;
}
case 4:
{
cout<<"Current interest rate: ";
A1.getinterestRate();
break;
}
case 5:
{
cout<<"Total interest is: ";
A1.calcInterest ();
A1.getinterest();
break;
}
case 6:
{
cout<<"Total transections are: ";
A1.gettransections(a);
break;
}
case 7:
{
A1.setInterestRate (IR);
}
case 8:
{
cout<<"EXITED!"<<endl;
break;
}
}
}
}

You might also like