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

Linked Lists C++ You have been hired by Employees, Inc to write an employee mana

ID: 3819915 • Letter: L

Question

Linked Lists C++

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>
#include<iomanip>
#include<stdio.h>
#include<malloc.h>
using namespace std;
//Creates a structure for Employee
struct Employee
{
//Structure members
long int empid;
int hours;
float payRate;
//Self reference pointer
struct Employee *next;
}*start = NULL;
//Renames to EMP
typedef struct Employee EMP;
//Creates temporary pointer
EMP *p, *q = NULL;
//Function to accept employee Id
void AcceptEmpID()
{
//Creates a pointer of type employee
p = (EMP *) malloc (sizeof(EMP));
//Accepts the employee id
cout<<" Enter a employee ID number: ";
cin>>p->empid;
//Checks for the first node
if(start == NULL)
{
//New pointer next is set to null
p -> next = NULL;
//Start points to the new node though it is the first node
start = p;
}//End of if
// Travers till end of the linked list
else
{
//Stores the start in a temporary pointer
q = start;
//Loops till end
while(q -> next != NULL)
//Moves to the next node
q = q -> next;
//Currently created node next is set to last node next
p -> next = q -> next;
//last node next is set to current node
q -> next = p;
}//End of else
}//End of function
//To accept hours, pay rate
void AcceptOtherInfo()
{
int x, hour;
float pay;
q = start;
//Loops till end of linked list
while(q != NULL)
{
cout<<endl<<"Enter the requested data for employee number: "<<q -> empid;
//Validates hours
do
{
//Accept hours
cout<<endl<<"Hours worked: ";
cin>>hour;
//Checks if hours is greater than zero then valid hours
if(hour > 0)
{
//Store the hours
q -> hours = hour;
//Come out of the do - while loop
break;
}//End of if
//Invalid hours: displays error message and loops again
else
cout<<endl<<"Hours must be greater than zero. Please re - enter!";
}while(1);
//Validates pay rate
do
{
//Accepts pay rate
cout<<endl<<"Pay rate: $";
cin>>pay;
//Checks if pay is greater than or equals 15.00 then valid pay
if(pay >= 15.00)
{
//Stores the pay
q -> payRate = pay;
//Come out of the do - while loop
break;
}//End of if
//Invalid pay: displays error message and loops again
else
cout<<endl<<"Pay rate must be 15.00 or more. Please re - enter!";
}while(1);
//Move to the next node
q = q -> next;
}//End of while loop
}//End of function

//To display employee information
void disp()
{
p = start;
cout<<endl<<"------------------------------------------------";
cout<<endl<<"Employee Wages";
cout<<endl<<" ------------------------------------------------";
//Loops till end of linked list
while(p != NULL)
{
cout<<endl<<"Employee "<<p -> empid;
cout<<" $"<<fixed<<setprecision(2)<<((p -> hours) * (p -> payRate));
//Move to the next node
p = p -> next;
}//End of while
}//End of function

//Main function
int main( )
{
char ch;
//Loops till user choice is Y or y
do
{
//Accepts employee id
AcceptEmpID();
cout<<endl<<"Enter your choice (Y/N) - ";
fflush(stdin);
//Accepts user choice
ch = getchar();
}while(ch == 'y' || ch == 'Y');
//Accepts hours and pay rate
AcceptOtherInfo();
//Displays employee information
disp();
exit(0);
}//End of main

Output:

Enter a employee ID number: 5658845

Enter your choice (Y/N) - y

Enter a employee ID number: 4520125

Enter your choice (Y/N) - y

Enter a employee ID number: 7895122

Enter your choice (Y/N) - n

Enter the requested data for employee number: 5658845
Hours worked: 23

Pay rate: $12.34

Pay rate must be 15.00 or more. Please re - enter!
Pay rate: $16.78

Enter the requested data for employee number: 4520125
Hours worked: 32

Pay rate: $23.45

Enter the requested data for employee number: 7895122
Hours worked: 21

Pay rate: $23.45

------------------------------------------------
Employee Wages
------------------------------------------------
Employee #5658845 $385.94
Employee #4520125 $750.40
Employee #7895122 $492.45

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