Friday, 15 November 2013

1. Given that an EMPLOYEE class contains the following members: Data Members: Employee_Number, Employee_Name, Basic, DA, IT,Net_Sal. Member Functions: to read data, to calculate Net_Sal and to print data members Write a C++ program to read data on N employees and compute the Net_Sal of eachemployee(DA = 52% of Basic and Income Tax = 30% of the gross salary)



#include <iostream.h>
#include <conio.h>
class EMPLOYEE //implments the EMPLOYEE class
{
 private:char employee_number[10],
employee_name[10];
float basic,DA,IT,net_sal;
 public:void Read_Data();                   
void Calculate_Net_Salary(); //calculates the net salary
void Display_Data(); //Displays the data
};
void EMPLOYEE::Read_Data()
{
cout << "Enter the Employee Number and Name" << endl;
cin >> employee_number >> employee_name;
cout << "Enter the Basic Salary" << endl;
cin >> basic;
}
void EMPLOYEE::Calculate_Net_Salary()
{
float Gross_Sal;DA = (52*basic)/100;
Gross_Sal = basic+DA;
IT = (30*Gross_Sal)/100;
net_sal = Gross_Sal-IT;
}
void EMPLOYEE::Display_Data()
{
cout << "Emp Name:" << employee_name << "\tEmp Number:" <<employee_number;
cout << "\t Net Salary:" << net_sal << endl;
}

void main()
{
int n,i;
clrscr();
cout << "Enter the number of employees: " ;
cin >> n;
cout << endl;
EMPLOYEE Emp[10];
cout << "Enter employee data" << endl;
for(i=0; i<n; i++)
{
Emp[i].Read_Data();
for(i=0;i<n;i++)
{
Emp[i].Calculate_Net_Salary();
Emp[i].Display_Data();
}

1 comment: