Design, develop, and execute a program in C++ based on the following requirements: An EMPLOYEE class is to contain the following data members and member functions: Data members: Employee_Number (an integer), Employee_Name (a string of characters), Basic_Salary (an integer), All_Allowances (an integer), IT (an integer), Net_Salary (an integer). Member functions: to read the data of an employee, to calculate Net_Salary and to print the values of all the data members. (All_Allowances = 123% of Basic; Income Tax (IT) = 30% of the gross salary (= basic_Salary _ All_Allowance); Net_Salary = Basic_Salary + All_Allowances – IT).





Implementation of the above problem:
#include<iostream.h>
#include<conio.h>
class employee
{
int num;
char name[20];
float basic,da,it,netsal;
public:void readdata();
void netsalary();
void display();
int getnum();
};
void employee::readdata()
{
cout<<"\n\n Enter employee number:";
cin>>num;
cout<<"\n Enter name:";
cin>>name;
cout<<"\n Enter basic:";
cin>>basic;
}
void employee::netsalary()
{
float sal;
da=0.52*basic;
sal=da+basic;
it=0.3*sal;
netsal=sal-it;
}
void employee::display()
{
cout.precision(4);
cout.setf(ios::right);
cout<<"\n"<<num;
cout.width(15);
cout<<name;
cout.width(10);
cout<<basic;
cout.width(10);
cout<<da;
cout.width(10);
cout<<it;
cout.width(10);
cout<<netsal;
}
int employee::getnum()
{
return num;
}
void main()
{
int i,n;
clrscr();
cout<<"\n Enter the number of employees:";
cin>>n;
employee e[20];
for(i=0;i<n;i++)
{
cout<<"\n Enter the details of employee "<<i+1;
e[i].readdata();
for(int j=0;j<i;j++)
{
if(e[i].getnum()==e[j].getnum())
{
cout<<"\n Duplicate entry of employee number,re-type";
i--;
}
}
}
for(i=0;i<n;i++)
e[i].netsalary();
cout<<"\nNUMBER\t NAME\t BASIC\tDA\t IT\t NET SALARY\n";



for(i=0;i<n;i++)
e[i].display();
getch();
}


Thanks
Mukesh Rajput
Mukesh Rajput

Mukesh Rajput

I am a Computer Engineer, a small amount of the programming tips as it’s my hobby, I love to travel and meet people so little about travel, a fashion lover and love to eat food, I am investing a good time to keep the body fit so little about fitness also..

Post A Comment:

0 comments:

Thanks
Mukesh Rajput