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

Payroll Write a program that uses the following . 5t inklist linklist empta a so

ID: 3919238 • Letter: P

Question

Payroll Write a program that uses the following . 5t inklist linklist empta a sof seven long integers to hold employee identification numbers. The-should be initialized with the following numbers: 045427-1302350 7580489 linklist hours: alert ofn iters to hld the number of hours worked by each employee payhate:auniayfseven douie s to hold each employee's hourty pay rate payRate vages: as aay of seven double s to hold each employee's gross wages inklist The program should relate the data in each array through the subscripts. For example, the number in element 0 of the hours 9uld be the number of hours worked by the employee whose identification number is stored in element 0 of the empId erray. That same employee's pay rate should be stored in element 0 of the paylate arraylinkist The program should display each employee number and ask the user to enter that employee's hours and pay rate. It should then calculate the gross wages for that employee (hours times pay rate) and store them in the ages 18Aher the data has been entered for all the employees, the program should display each employee's identification number and gross wages Input Validation: Do not accept negative values for hours or numbers less than 15.00 for pay rate ink list. use linklist write a Poospamm in C++

Explanation / Answer

#include<iostream>

#include<malloc.h>

using namespace std;

struct emp_id

{

long int id;

struct emp_id *next;

};

struct hrs

{

int hr;

struct hrs *next;

};

struct pay

{

double rate;

struct pay *next;

};

struct wage

{

double w;

struct wage *next;

};

int main()

{

struct emp_id *first,*emp2,*emp3,*emp4,*emp5,*emp6,*emp7,*temp;

//initializing all employee ids----------------------

first=(struct emp_id *)malloc(sizeof(struct emp_id));

first->id=3638845;

emp2=(struct emp_id *)malloc(sizeof(struct emp_id));

emp2->id=4520125;

first->next=emp2;

emp3=(struct emp_id *)malloc(sizeof(struct emp_id));

emp3->id=7895122;

emp2->next=emp3;

emp4=(struct emp_id *)malloc(sizeof(struct emp_id));

emp2->id=8777541;

emp3->next=emp4;

emp5=(struct emp_id *)malloc(sizeof(struct emp_id));

emp2->id=8451277;

emp4->next=emp5;

emp6=(struct emp_id *)malloc(sizeof(struct emp_id));

emp6->id=1302953;

emp5->next=emp6;

emp7=(struct emp_id *)malloc(sizeof(struct emp_id));

emp7->id=7560489;

emp6->next=emp7;

emp7->next=NULL;

//initializations completed------------------

int i=0;

temp=first;

while (temp!=NULL)

{

cout<<"id of employee"<<i+1<<"is "<<temp->id<<" ";

temp=temp->next;

i++;

}

//working hours----------------------

struct hrs *first_hr=NULL,*newemp,*last;

i=0;

while (i!=7)

{

cout<<"employee "<<i+1<<"hrs="<<" ";

if (first_hr==NULL)

{

first_hr=(struct hrs*)malloc(sizeof(struct hrs));

cin>>first_hr->hr;

last=first_hr;

first_hr->next=NULL;

if (first_hr->hr<0)

{

cout<<"enter positive value ";

cout<<"employee "<<i+1<<"hrs="<<" ";

cin>>first_hr->hr;

}

}

else

{

newemp=(struct hrs*)malloc(sizeof(struct hrs));

cin>>newemp->hr;

last->next=newemp;

newemp->next=NULL;

last=newemp;

if (newemp->hr<0)

{

cout<<"enter positive value ";

cout<<"employee "<<i+1<<"hrs="<<" ";

cin>>newemp->hr;

}

}

i++;

}

//end--------------------------------------

//payments---------------------------------------

struct pay *first_pay=NULL,*nn,*final;

i=0;

while (i!=7)

{

cout<<"employee "<<i+1<<"payment="<<" ";

if (first_pay==NULL)

{

first_pay=(struct pay *)malloc(sizeof(struct pay));

cin>>first_pay->rate;

final=first_pay;

first_pay->next=NULL;

if (first_pay->rate<15.0)

{

cout<<"enter value>15 ";

cout<<"employee "<<i+1<<"payment="<<" ";

cin>>first_pay->rate;

}

}

else

{

nn=(struct pay *)malloc(sizeof(struct pay));

cin>>nn->rate;

final->next=nn;

nn->next=NULL;

final=nn;

if (nn->rate<15.0)

{

cout<<"enter value>15 ";

cout<<"employee "<<i+1<<"payment="<<" ";

cin>>nn->rate;

}

}

i++;

}

struct pay *temp1=first_pay;

/*temp1=first_pay;

while (temp1!=NULL)

{

cout<<temp1->rate<<" ";

temp1=temp1->next;

}*/

//end----------------------

//wages----------------------------

temp1=first_pay;struct hrs *temp2=first_hr;

struct wage *first_wage=NULL,*nn1,*final1;

i=0;

while (i!=7)

{

if (first_wage==NULL)

{

first_wage=(struct wage *)malloc(sizeof(struct wage));

first_wage->w=temp1->rate*temp2->hr;

final1=first_wage;

first_wage->next=NULL;

}

else

{

nn1=(struct wage *)malloc(sizeof(struct wage));

nn1->w=temp1->rate*temp2->hr;

final1->next=nn1;

nn1->next=NULL;

final1=nn1;

}

temp1=temp1->next;temp2=temp2->next;

i++;

}

//end--------------

i=0;

temp=first;

cout<<"----------------------------------- ";

while (temp!=NULL)

{

cout<<"id of employee"<<i+1<<"is "<<temp->id<<" ";

temp=temp->next;

i++;

}

i=0;

cout<<"------------------------------------ ";

struct wage * temp3=first_wage;

while (temp3!=NULL)

{

cout<<"wage of employee "<<i+1<<"is ="<<temp3->w<<" ";

temp3=temp3->next;

i++;

}

cout<<"------------------------------------";

return 0;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote