Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

the first 10 records in your data The first 10 records in your data file each co

ID: 3695093 • Letter: T

Question

the first 10 records in your data The first 10 records in your data file each contain a pay code and the corresponding pay rate per hour, the remaining records in the file are 1 per employee, and each record contains an employee name, hours worked, and pay code. Your are to output for each employee his/her name, hours worked, pay rate per hour, and gross pay. Dont worry about overtime. You may assume that the employee's pay code will be one of the initial 10 pay codes. Validate the hours worked(must be great than 0).

Explanation / Answer

include<iostream.h>
#include<conio.h>
#define SIZE 10
class employee
{
   float basic,da,it,netsal;
   char name[20],num[10];

int hours_worked;

int pay_rate_per_hour;

int gross pay;;
   public:
       void getdata();
       void calculatepay();
       void displaydata();

};

void employee::getdata()
   {
      cout<<"             Enter employee number: " ;
      cin>>name;
      cout<<"              Enter employee name: " ;
      cin>>num;
      cout<<"Enter pay rate per hour " ;
      cin>>pay_rate_per_hour;

cout<<”hours worked”;

cin>>hours_worked;
   }

void employee::calculatepay()
   {
     grosspay=pay_rate_per_hour*hours_worked;

      }
void employee::displaydata()
   {
      cout
           <<"       Employee number: "<<name
           <<"         Employee name: "<<num
           <<"    Employee netpay: "<<grosspay<<" Rs.";

   }

void main()
{
   clrscr();
   employee z[SIZE];
   int n;
   cout<<" ***********************************"
         <<" Calculation of Employee Net Salary"
         <<" ***********************************"
         <<" Enter the number of employees";
   cin>>n;
   for(int i=0;i<n;i++)
       {
           z[i].getdata();
           z[i].calculatepay();
       }
     clrscr();
   cout<<" -----------------"
         <<" Employee Detail::"
         <<" -----------------";
   for( i=0;i<n;i++)
          {
           cout<<" Employee:"<<i+1
               <<" ----------";
           z[i].displaydata();
          }
   getch();
}