Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

OOPS LAB PROGRAM 1-2

1.Given that an EMPLOYEE class contains following members: Employee Number, Employee
Name, Basic, DA, IT, Net Salary. Member functions: to read the data, to calculate Net Salary
and to print data members. Write a C++ program to read the data of N employees and
compute Net Salary of each employee. (Dearness Allowance (DA) = 52% of Basic and Income
Tax (IT) = 30% of the gross salary. Net Salary = Basic + DA - IT).

#include<iostream>

using namespace std;

class employee

/*Employee Number, Employee Name, Basic, DA, IT, Net Salary.*/

int Eno;

string name;

float basic,da,it,net_sal = 0.0;

public:

void read()

cout<<"Enter the employee details \n"<<endl;

cout<<"Enter the employee number :";

cin>>Eno;

cout<<"Enter the employee name :";

cin>>name;

cout<<"Enter the employee basic salary :";

cin>>basic;

}
void compute();

void display()

cout<<endl;

cout<<"Employee number is "<<Eno<<endl;

cout<<"Employee name is"<<name<<endl;

cout<<"Employee Basic Salary is"<<basic<<endl;

cout<<"The Net Salary is "<<net_sal<<endl;

cout<<endl;

};

void employee::compute()

da = 0.52*basic;

it = 0.30*basic;

net_sal = basic + da - it;

int main()

int n;

cout<<"Enter number of employees ";

cin>>n;
employee e[n];

for(int i=0;i<n;i++)

e[i].read();

e[i].compute();

e[i].display();

return 0;

}
2. Write a C++ program to Create array of objects of class student with data members for
storing his USN marks of six subjects for three tests and member functions to input display
and calculate the avg marks for each subject taking best two of three marks. Write a tester
program to test these classes.

You might also like