Thursday, September 13, 2012

C++ PROGRAM TO CALCULATE EMPLOYEE NET SALARY





Given that an EMPLOYEE class contains following members:
Data 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.h>
#include<conio.h>
#define SIZE 5

class emp
  {
     float basic,da,it,netsal;
     char name[20],num[10];
     public:
         void getdata();
         void net_sal();
         void dispdata();

  };

void emp::getdata()
    {
      cout<<"\n            Enter employee number: " ;
      cin>>name;
      cout<<"              Enter employee name: " ;
      cin>>num;
      cout<<"Enter employee basic salary in Rs: " ;
      cin>>basic;
    }

void emp::net_sal()
    {
      da=((0.52)*basic );
      float gsal=da+basic;
      it=((0.3)*gsal);
      netsal=gsal-it;
    }

void emp::dispdata()
    {
      cout
            <<"\n      Employee number: "<<name
            <<"\n        Employee name: "<<num
            <<"\n   Employee netsalary: "<<netsal<<" Rs.";

    }

void main()
  {
     clrscr();
     emp ob[SIZE];
     int n;
     cout<<"\n\n***********************************"
         <<"\nCalculation of Employee Net Salary"
         <<"\n***********************************"
         <<"\n Enter the number of employees";
     cin>>n;
     for(int i=0;i<n;i++)
         {
            ob[i].getdata();
            ob[i].net_sal();
         }
     clrscr();
     cout<<"\n-----------------"
         <<"\nEmployee Detail::"
         <<"\n-----------------";
     for( i=0;i<n;i++)
          {
            cout<<"\n\n Employee:"<<i+1
                <<"\n ----------";
            ob[i].dispdata();
          }
     getch();
  }





OUTPUT




No comments:

Post a Comment