Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can help to write a C program that determines the gross pay for each employee in a company. The company pays straight-time for the first

Can help to write a C program that determines the gross pay for each employee in a company. The company pays "straight-time" for the first 160 hours worked by each employee for four weeks and pays "time-and-a-half" for all hours worked in excess of 160 hours. You are given a list of employee Ids (an integer), the number of hours each employee worked for the four weeks, and the hourly rate of each employee. The program should input this information for each employee, then determine and display the employee's gross pay. The sentinel value of -1 is used for the employee id to indicate the end of input.

Your program should include three functions, apart from the main() function, to handle the input, and the computation of the gross pay.

The function prototypes for the functions are given as follows

#include

void readInput(int *id, int *noOfHours, int *payRate);

double computeSalary1(int noOfHours, int payRate);

void computeSalary2(int noOfHours, int payRate, double *grossPay);

int main()

{

int id = -1, noOfHours, payRate;

double grossPay;

readInput(&id, &noOfHours, &payRate);

while (id != -1) {

printf("computeSalary1(): ");

grossPay = computeSalary1(noOfHours, payRate);

printf("ID %d grossPay %.2f ", id, grossPay);

printf("computeSalary2(): ");

computeSalary2(noOfHours, payRate, &grossPay);

printf("ID %d grossPay %.2f ", id, grossPay);

Page 3

readInput(&id, &noOfHours, &payRate);

}

return 0;

}

void readInput(int *id, int *noOfHours, int *payRate)

{

/* input your code here */

}

double computeSalary1(int noOfHours, int payRate)

{

/* input your code here */

}

void computeSalary2(int noOfHours, int payRate, double *grossPay)

{

/* input your code here */

}

Some sample input and output sessions are given below:

(1) Test Case 1:

Enter ID (-1 to end):

11

Enter number of hours:

155

Enter hourly pay rate:

8

computeSalary1(): ID 11 grossPay 1240.00

computeSalary2(): ID 11 grossPay 1240.00

Enter ID (-1 to end):

12

Enter number of hours:

165

Enter hourly pay rate:

8

computeSalary1(): ID 12 grossPay 1340.00

computeSalary2(): ID 12 grossPay 1340.00

Enter ID (-1 to end):

-1

(2) Test Case 2:

Enter ID (-1 to end):

11

Enter number of hours:

155

Enter hourly pay rate:

8

computeSalary1(): ID 11 grossPay 1240.00

computeSalary2(): ID 11 grossPay 1240.00

Enter ID (-1 to end):

12

Enter number of hours:

160

Enter hourly pay rate:

8

computeSalary1(): ID 12 grossPay 1280.00

computeSalary2(): ID 12 grossPay 1280.00

Enter ID (-1 to end):

13

Enter number of hours:

200

Enter hourly pay rate:

8

computeSalary1(): ID 13 grossPay 1760.00

computeSalary2(): ID 13 grossPay 1760.00

Page 4

Enter ID (-1 to end):

-1

Hi I need help on how to do up this code in C programming especially ReadInput.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions