You are on page 1of 4

OOP

LAB REPORT
NAME Muhammad Hamza Aamir
ROLL NO FA20-BEE-122
SECTION BEE-3C

LAB TASK:
#include <iostream>
using namespace std;
class saving_account
{
static float annual_interest_rate;
int saving_balance;
float monthly_interest;
public:
saving_account(int x)
{
saving_balance=x;

}
void calculate_monthly_interest()
{
monthly_interest=(annual_interest_rate*saving_balance)/12;
saving_balance=monthly_interest;
cout<<"the monthly interest of saver is :"<<monthly_interest;
}
static void modify_interest_rate()
{
cout<<"enter new value of annual_interest_rate :\n";
cin>>annual_interest_rate;
}
};
float saving_account::annual_interest_rate=0.03;
int main()
{saving_account saver1(2000),saver2(3000);
saver1.calculate_monthly_interest();
cout<<"\n";
saver2.calculate_monthly_interest();
cout<<"\n";
saver1.modify_interest_rate();
saver1.calculate_monthly_interest();

return 0;
}
TASK 2:
#include <iostream>
using namespace std;
class Object
{
static int count;
int i;
public:
Object()
{

count++;

}
static void objects()
{
cout<<"created objects:"<<count;
}
~Object()
{
count--;
}
void object()
{
cout<<"destroyed objects:"<<count;
}
};
int Object::count=0;
int main()
{
Object obj1,obj2,obj3;
Object::objects();
cout<<"\n";
obj3.object();

return 0;
}

You might also like