0% found this document useful (0 votes)
179 views3 pages

OOP Assignment#1 (181209) Program Code

The document defines a BankAccount class with methods for depositing, withdrawing, calculating interest, and getting account balances and rates. It includes a main function that uses a BankAccount object to simulate basic account functions like making deposits and withdrawals, checking balances and rates, and setting a new interest rate. The user is presented with a menu of options to perform these functions in a loop until exiting.

Uploaded by

Ali Ahmad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
179 views3 pages

OOP Assignment#1 (181209) Program Code

The document defines a BankAccount class with methods for depositing, withdrawing, calculating interest, and getting account balances and rates. It includes a main function that uses a BankAccount object to simulate basic account functions like making deposits and withdrawals, checking balances and rates, and setting a new interest rate. The user is presented with a menu of options to perform these functions in a loop until exiting.

Uploaded by

Ali Ahmad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 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