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

In C++ for data structures class: You have been hired by Employees, Inc to write

ID: 3819062 • Letter: I

Question

In C++ for data structures class:

You have been hired by Employees, Inc to write an employee management system. The following are your specifications:

Write a program that uses the following linked lists:

empId: a linked list of seven long integers to hold employee identification numbers. The array should be initialized with the following numbers: 5658845 4520125 7895122 8777541 8451277 1302850 7580489

hours: a linked list of seven integers to hold the number of hours worked by each employee

payRate: any data structure (your choice) of seven doubles to hold each employee’s hourly pay rate

wages: a linked list of seven doubles to hold each employee’s gross wages

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 wages array. After 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.

When the program starts, it should ask the user to enter the employee IDs. There should be no limit on the number of IDs the user can enter.

The following screenshot shows a small subset of an example program run:

Explanation / Answer

#include<iostream>
using namespace std;
struct emp{
   int empId;
   int hours;
   double payRate;
   double wages;
   struct emp * next;
};
void push(struct emp** head_ref, int eid,int hour,double rate, double wage)
{

struct emp* new_node = new struct emp;
new_node->empId = eid;
new_node->hours = hour;
new_node->payRate = rate;
new_node->wages = wage;
new_node->next = (*head_ref);
(*head_ref) = new_node;
}
void printAll(struct emp *head){
   int i=1;
   while(head!=NULL){
       cout<<"Employee "<<(i+1)<<" : "<<endl;
       cout<<"EmpId: "<<head->empId<<endl<<"Hours : "<<head->hours<<endl<<"Pay Rentel: "<<head->payRate;
       cout<<endl<<"Wages : "<<head->wages<<endl;
       head=head->next;
   }
}
int main(){
   struct emp *head;
   char choice;
   int arr[]={5658845, 4520125, 7895122, 8777541, 8451277, 1302850, 7580489};
   int hour;
   double payRate;
   double wages;
   for(int i=0;i<7;i++){
       cout<<"Employee "<<(i+1)<<endl;
       cout<<"Enter hour : ";
       cin>>hour;
       while(hour<0){
           cout<<"Enter hours non negative : ";      
           cin>>hour;
       }
       cout<<"Reenter Pay Ratel : ";
       cin>>payRate;
       while(payRate<15){
           cout<<"Reenter payRatel more than equal to 15 : ";
           cin>>payRate;      
       }
       wages = hour*payRate;
       push(&head,arr[i],hour,payRate,wages);
   }
   int i=7;
   int empid;
   cout<<"Do you want to enter more element than enter Y else N";
   cin>>choice;
   while(choice=='Y' || choice=='y'){
       cout<<"Employee "<<(i+1)<<endl;
       cout<<"Enter Emp Id : ";
       cin>>empid;
       cout<<"Enter hour : ";
       cin>>hour;
       while(hour<0){
           cout<<"Enter hours non negative : ";      
           cin>>hour;
       }
       cout<<"Reenter Pay Ratel : ";
       cin>>payRate;
       while(payRate<15){
           cout<<"Reenter payRatel more than equal to 15 : ";
           cin>>payRate;      
       }
       wages = hour*payRate;
       push(&head,empid,hour,payRate,wages);
       i++;
       cout<<"Do you want to enter more element than enter Y else N : ";
       cin>>choice;
   }
   cout<<endl<<endl;
   printAll(head);  
   return 0;
}