OOp Assignment 1
OOp Assignment 1
Department
Information Technology
Submitted To
Sir Ahmad Amin
Submitted By
Zeeshan Basharat
Roll no.
BITM-F21-070
Question # 2:
#include<iostream>
using namespace std;
class student {
protected:
string ID;
string name;
string address;
string phone_no;
public:
student()
{
this->ID = "";
this->name = "";
this->address = "";
this->phone_no = "";
}
void setID(string id) {
this->ID = id;
}
void setname(string name) {
this->name = name;
}
void setaddress(string address) {
this->address = address;
}
void setphone_no(string phone)
{
this->phone_no = phone;
}
string getID() {
return this->ID;
}
string getname() {
return this->name;
}
string getaddress() {
return this->address;
}
string getphone_no()
{
return this->phone_no;
}
};
return 0;
}
Question # 1:
#include<iostream>
using namespace std;
class Employee
{
string employee_name;
int employee_id;
string employee_address;
double employee_phone_No;
public:
void setemployee_name(string a) {
this->employee_name=a;
}
string getemployee_name() {
return this->employee_name;
}
void setemployee_id(int b) {
this->employee_id=b;
}
int getemployee_id(){
return this->employee_id;
}
void setemployee_address(string c) {
this->employee_address=c;
}
string getemployee_address(){
return this->employee_address; }
void setemployee_phone_No(double d){
this->employee_phone_No=d;
}
double getemployee_phone_No(){
return this->employee_phone_No;
}
};
class Salary
{
int employee_leave;
double employee_monthly_income;
public:
void input();
void disp();
};
void Salary::input()
{
cout<<"Enter the Monthly Income:";
cin>>employee_monthly_income;
}
void Salary::disp()
{
for(int i=1;i<=5;i++)
{
cout<<"Enter the days Employee is on leave:"<<endl;
cin>>employee_leave;
if(employee_leave>=1)
{
cout<<"Enter the detuction % the Employee is on leave:"<<endl;
cout<<"Your Monthly income after detuction is = "<<employee_monthly_income-
((employee_monthly_income*5 /100))<<endl;
}
else if(employee_leave==0)
{
cout<<"Your Monthly income = "<<employee_monthly_income<<endl;
}}}
int main()
{
string name;
int id;
string address;
double phone_No;
Employee obj;
cout<<"Enter the Name of Employee:";
cin>>name;
obj.setemployee_name(name);
cout<<"Enter the Id of Employee:";
cin>>id;
obj.setemployee_id(id);
cout<<"Enter the Address of Employee:";
cin>>address;
obj.setemployee_address(address);
cout<<"Enter the phone no of Employee:";
cin>>phone_No;
obj.setemployee_phone_No(phone_No);
cout<<"The name of Employee="<<obj.getemployee_name()<<endl;
cout<<"The id of Employee="<<obj.getemployee_id()<<endl;
cout<<"The adress of Employee="<<obj.getemployee_address()<<endl;
cout<<"The phone no of Employee ="<<obj.getemployee_phone_No()<<endl;
Salary obj1;
obj1.input();
obj1.disp();
}