You are on page 1of 9

IUBAT-International University of Business Agriculture and Technology

Project-1

Course Name: Programming in c++ LAB


Course code: CSC-284

Prepared For
Jabunnesa Jahan Sara
Lecturer (IUBAT)

Prepared By
MD. Ashraful Haque
Section:F
ID: 22103225
Serial: 25

Date of Submission: 19 December 2022


#include <bits/stdc++.h>

using namespace std;

class Bank
{
protected:

float money,saving;

int year;

public:

Bank() {}

void setmoney(float amount)


{
current_amount = amount;
}

void setsaving (float s)


{
saving = s;
}

virtual void displaymoney() = 0;


virtual void displaysaving() = 0;
};

class BankA : public Bank


{
private:
float interest = 7;
public:
void calculation(int y)
{
year = y;
saving = saving + (saving * ((interest / 100) * year));
}

void displaymoney()
{
cout << endl;
cout << "\t\t\t\tMoney in bankA = " << current_amount << endl;
}

void displaysaving()
{
cout << endl;
cout << "\t\t\t\tSaving in bankA = " << saving << endl;
}
};

class BankB : public Bank


{
private:
float interest = 5;

public:
void calculation(int y)
{
year = y;
saving = saving + (saving * ((interest / 100) * year));
}

void displaymoney()
{
cout << endl;
cout << "\t\t\t\tMoney in bankB = " << current_amount << endl;
}

void displaysaving()
{
cout << endl;
cout << "\t\t\t\tSaving in bankB = " << saving << endl;
}
};

int main()
{
Bank *ptr;
BankA o1;
BankB o2;

float current_amount;
float salary = 0;
bool trans = true;
int year;
float sav;
float saving = 0;

string Name;

cout << endl;

cout<<"\t\t\t\tEnter Your name : ";


cin>>Name;

cout << "\t\t\t\tEnter the initial salary(monthly) : ";


cin >> current_amount;

salary += current_amount;
int choice;

do
{
cout << endl;
cout << "\t\t\t---------------YEARLY--------------"<< endl;
cout << "\t\t\t\tpress 1 to add yearly salary" << endl;
cout << "\t\t\t\tpress 2 to add saving" << endl;
cout << "\t\t\t\tpress 3 to show the saving amount in bank B" << endl;
cout << "\t\t\t\tPress 4 to transfer the amount to bank A"<< endl;
cout << "\t\t\t\tPress 5 to show the saving in bank A" << endl;

cout << "\t\t\t\tpress 6 to quit" << endl;


cout << "\t\t\t\tEnter a choice : ";
cin >> choice;
cout << endl;
cout << "\t\t\t---------------------------------------------" << endl;

switch(choice)
{
case 1:

cout << endl;


cout << "\t\t\t\tEnter the amount : ";
cin >> current_amount;
salary += current_amount;
break;

case 2:

cout << endl;


cout << "\t\t\t\tEnter the amount u want for saving : ";
cin >> sav;
if (sav > salary)
{
cout << "\t\t\t\tInvalid choice" << endl;
}
else
{
saving += sav;
salary -= sav;
}
break;

case 3:

if (trans)
{
o2.setsaving(saving);
cout << endl;
cout << "\t\t\t\tEnter the year : ";
cin >> year;

o2.calculation(year);
ptr = &o2;
cout<<endl;
cout<<"\t\t\t\tClient Name : "<<Name<<endl;
ptr->displaysaving();
}

else
{
o2.setsaving(0);
o2.calculation(1);
ptr = &o2;
cout<<endl;
cout<<"\t\t\t\tClient Name : "<<Name<<endl;
ptr->displaysaving();
}
break;

case 4:

trans = false;
cout << endl;
cout<<endl;
cout<<"\t\t\t\tClient Name : "<<Name<<endl;
cout << "\t\t\t\tMoney transfer complete !! " << endl;

break;

case 5:

o1.setsaving(saving);
cout << endl;
cout << "\t\t\t\tEnter the year : ";
cin >> year;
o1.calculation(year);
ptr = &o1;
cout<<endl;
cout<<"\t\t\t\tClient Name : "<<Name<<endl;
ptr->displaysaving();

break;
case 6: break;
default:
cout << endl;
cout << "\t\t\t\tInvalid choice !!!! " << endl;

}
} while (choice != 7);
return 0;
}

You might also like