Task#11 Assignment in C++
#include<iostream>
using namespace std;
class Person //Common Person has Fixed Salary with Bonus of 5%
{
float Salary;
public:
void getdata(float s)
{
Salary=s;
}
void display()
{
cout<<"\n\n\n5% is the Bonus of Common Person. Its Bonus is: "<<Salary;
}
void Bonus()
{
Salary=(Salary*0.05);
}
};
class Admin:public Person //Admin Person has Fixed Salary with Bonus of 20%
{
float Salary;
public:
void getdata(float s)
{
Salary=s;
}
void display()
{
cout<<"\n\n\n20% is the Bonus of Admin Person. Its Bonus is: "<<Salary;
}
void Bonus()
{
Salary=(Salary*0.2);
}
};
class Salesman:public Person //Salesman has Fixed Salary with Bonus of 10% Only
{
float Salary;
public:
void getdata(float s)
{
Salary=s;
}
void display()
{
cout<<"\n\n\n10% is the Bonus of Salesman. Its Bonus is: "<<Salary<<"\n\n\n";
}
void Bonus()
{
Salary*=0.1;
}
};
int main()
{
cout<<"\n\t\t\a\e\tBonus Calculation\n\n";
Person Ahmed; //Want to Give Common Person Salary and Finds its Bonus
Ahmed.getdata(12223.23); //Set Salary
Ahmed.Bonus(); //Member Function of Bonus Calculater
Ahmed.display(); //Display Bonus Only of Common Person
Admin Ali; //Want to Give Admin Person Salary and Finds its Bonus
Ali.getdata(43567.89); //Set Salary
Ali.Bonus(); //Member Function of Bonus Calculater
Ali.display(); //Display Bonus Only of Admin Person
Salesman Saleem; //Want to Give Sales Person Salary and Finds its Bonus
Saleem.getdata(61323.35); //Set Salary
Saleem.Bonus(); //Member Function of Bonus Calculater
Saleem.display(); //Display Bonus Only of Sales Person
}
Comments
Post a Comment