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

The PC Pine Furniture Company has recently hired you to help them generate a pay

ID: 3692319 • Letter: T

Question

The PC Pine Furniture Company has recently hired you to help them generate a payroll report for all their employees. You are given a data file containing the employee’s data. The data for each employee consists of the employee id, name, hours worked and rate of pay. There are 15 employees in the file.

You are to write functions that does the following:

Read this data into parallel arrays, calculate the gross pay, for each employee by multiplying the hours by the rate and storing it in a gross array.

Write a function that prints the id, name and gross pay for all the employees whose gross is above $500.00.

Write a function that sorts the arrays, in ascending order, based on id, using the selection sort (procedure is in the book). In the function place a counter to count the number of comparisons it took before the array was sorted.

Write a function that prints the arrays after sorting including the number of comparisons.

Write a function that requests an id number and displays the name and gross for the person with that id number. This function calls the following binary search function.

A binary search function that will return the position of a requested id number.

Requirements:  

Every function must have specifications in the form of comments.

Make sure every function accomplishes a task and is self-contained

Use typedef to define new types as necessary.

Each output has a heading and labels to identify information.

Must test if data file exists before reading data.

main is used as a driver function, no input/output or calculations are done in main, only what is specified.

Output is sent to file(s)

***** DATA FILE ****

Explanation / Answer

void main(); # the main function

{

int empid[15], hour[15], rate[15]; # defining the arrays

string name[15];

ifstream inputFile; # To read the file

inputFile.open(“file.txt”);

for (int k=0;k<15;k++)

{

inputFile>>empid[k]>>name[k]>>hour[k]>>rate[k];

}

inputFile.close

grossPay(empid,hour,rate,name,15); # calling the function which calculates the grossPay

sort(empid,hour,rate,name,15); # calling the function to sort the arrays

}

#Function to calculate gross pay

void grossPay(int empid[], int hour[], int rate[], string name[], int size)

{ int gross[size];

for(int i=0;i<size;i++)

{gross[i]= hour[i]*rate[i];

if(gross[i]>500)

{printf(“Employee details with grossPay more than 500 is ”);

printf(“Employeeid is %d”,empid[i],”/n”);

printf(“Employee name is %c”, name[i], “/n”);

printf(“GrossPay is %d”,gross[i],”/n”);

}}

requesteid(empid,name,gross,15); # function to print details of requested id

}

void requested(int empid[],int gross[], string name[],15)

{

int id;

printf(“Please enter the id of employee whose details you want to see/n”);

scanf(“%d”,id);

for(i=0;i<size;i++)

{

if(empid[i]==id)

{printf(“Name of the person is %c”,name[i],”/n”);

printf(“Gross Pay of the person is %d”,gross[i],”/n”);

}

}

}

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