Question

C++ Linked Lists

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: empld: 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 employees hourly pay rate wages: a linked list of seven doubles to hold each employees gross wages The program should display each employee number and ask the user to enter that employees 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 employees 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 Enter an employee ID number 5658845 Do you want to enter another one v Enter an employee ID number 4520125 Do you want to enter another one v Enter an employee ID number 7895122 Do you want to enter another one 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 $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: 2 3 45 Employee Wages Employee #5 658845 385.94 Employee #4520125 750.40 Employee #7895 122 492.45

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code:

#include<iostream>
using namespace std;
struct Emp
{
int empid;
int hours;
double payrate;
double wage;
Emp *next;
}*head,*tail;

insert_node( int id)
{
if(head==NULL)
{
head=new Emp;
head->empid=id;
head->hours=0;
head->payrate=0;
head->wage=0;
head->next=NULL;
tail=head;
}
else
{
Emp *node=new Emp;
node->empid=id;
node->hours=0;
node->payrate=0;
node->wage=0;
node->next=NULL;
tail->next=node;
tail=tail->next;
}
}
void print_wages()
{
cout<<"\n---------------------------------\n";
cout<<"Employee\t\twages\n\n";

struct Emp *itr=head;
while(itr)
{
cout<<"Employee #"<<itr->empid<<"\t"<<"$ "<<itr->wage<<endl;
itr=itr->next;
}
}

void take_input()
{
struct Emp * itr;
itr=head;
while(itr)
{
double hr,pr;
cout<<"\nEnter the requested data for employee number "<<itr->empid;

do
{
cout<<"\n\tHours worked:";
cin>>hr;
if(hr <0)
{
cout<<"invalid hours: Please reenter:\n";
}
}while(hr<=0);

itr->hours=hr;
do
{
cout<<"\n\tPay rate: $";
cin>>pr;
if(pr<15)
{
cout<<"Pay rate is less that 15 please reenter \n";
}

}while (pr<15);

itr->payrate=pr;
itr->wage=pr*hr;
itr=itr->next;
}
}
int main()
{
struct Emp * node;
char ch;
do
{
int id;
cout<<"\nEnter an employee ID number:";
cin>>id;
insert_node(id);
cout<<"\nDo you want to enter another one?";
cin>>ch;

}while(ch=='y'||ch=='Y');

take_input();
print_wages();
return 1;
}

Output:

Enter an employee ID number: 5658845 Do you want to enter another one?y Enter an employee ID number:4520125 Do you want to en

Add a comment
Know the answer?
Add Answer to:
C++ Linked Lists You have been hired by Employees. Inc to write an employee management system....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Program is to be written In C++, The output should look like the screen shot. It...

    Program is to be written In C++, The output should look like the screen shot. It should allow the user to continue to ask the user to enter all employee ID's until done and then prompt the user to enter the hours and pay rate for each employee ID. Please help:( Can you please run the program to make sure the output is just like the screenshot please? It needs to have the output that is in the screenshot provided,...

  • EmpId: An array of seven Integers to hold employee identification numbers. The array should be in...

    C# please... Design a program that uses the following parallel arrays: empId: An array of seven Integers to hold employee identification numbers. The array should be initialized with the following numbers: 56588 45201 78951 87775 84512 13028 75804 hours: An array of seven Integers to hold the number of hours worked by each employee payRate: An array of seven Reals to hold each employee's hourly pay rate wages: An array of seven Reals to hold each employee's gross wages. The...

  • in C++ Write a program which uses the following arrays: empID: An array of 7 integers...

    in C++ Write a program which uses the following arrays: empID: An array of 7 integers to hold employee identification numbers. The array should be initialized with the following values: 1, 2, 3, 4, 5, 6, 7. Hours: an array of seven integers to hold the number of hours worked by each employee. payRate: an array of seven doubles to hold each employee’s hourly pay rate. Wages: an array of seven doubles to hold each employee’s gross salary. The program...

  • I hope some one can help me with the Python excercise (coding) Design a program that...

    I hope some one can help me with the Python excercise (coding) Design a program that uses the following parallel arrays: ● empId: An array of seven Integers to hold employee identification numbers. The array should be initialized with the following numbers: 56588 45201 78951 87775 84512 13028 75804 ● hours: An array of seven Integers to hold the number of hours worked by each employee. ● payRate: An array of seven Reals to hold each employee’s hourly pay rate....

  • C++ Program The Ward Bus Manufacturing Company has recently hired you to help them convert their...

    C++ Program The Ward Bus Manufacturing Company has recently hired you to help them convert their manual payroll system to a computer-based system. Write a program to produce a 1-week payroll report for only one employee to serve as a prototype (model) for the administration to review. Input for the system will be the employee’s 4-digit ID number, the employee’s name, hours worked that week, and the employee’s hourly pay rate. Output should consist of the employee’s ID number, the...

  • In C++ Please please help.. Assignment 5 - Payroll Version 1.0 In this assignment you must create and use a struct to hold the general employee information for one employee. Ideally, you should use an...

    In C++ Please please help.. Assignment 5 - Payroll Version 1.0 In this assignment you must create and use a struct to hold the general employee information for one employee. Ideally, you should use an array of structs to hold the employee information for all employees. If you choose to declare a separate struct for each employee, I will not deduct any points. However, I strongly recommend that you use an array of structs. Be sure to read through Chapter...

  • Design a Payroll class with the following fields:

    IN JAVADesign a Payroll class with the following fields:• name: a String containing the employee's name• idNumber: an int representing the employee's ID number• rate: a double containing the employee's hourly pay rate• hours: an int representing the number of hours this employee has workedThe class should also have the following methods:• Constructor: takes the employee's name and ID number as arguments• Accessors: allow access to all of the fields of the Payroll class• Mutators: let the user assign values...

  • In header file (.h) and c++ file format (.cpp). A local company has asked you to...

    In header file (.h) and c++ file format (.cpp). A local company has asked you to write a program which creates an Employee class, a vector of Employee class objects, and fills the objects with employee data, creating a "database" of employee information. The program allows the user to repeatedly search for an employee in the vector by entering the employee's ID number and if found, display the employee's data. The Employee_C class should have the following data and in...

  • You are to write a program that will process employees and their pay. For each employee...

    You are to write a program that will process employees and their pay. For each employee the program will read in an employee’s name and hourly pay rate. It should also read in the number of hours worked each day for 5 days and calculate his or her total number of hours worked. You must read the hours using a loop. The program should output the employee’s name, gross pay, total withholding amount and net pay. Withholding is made up...

  • java Payroll class Exceptions Programming Challenge 5 of Chapter 6 required you to write a Payroll...

    java Payroll class Exceptions Programming Challenge 5 of Chapter 6 required you to write a Payroll class that calculates an employee’s payroll. Write exception classes for the following error conditions: • An empty string is given for the employee’s name. • An invalid value is given for the employee’s ID number. If you implemented this field as a string, then an empty string would be invalid. If you implemented this field as a numeric variable, then a negative number or...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT