Write a C program that will calculate the gross pay of a set of employees.

For each employee the program should prompt the user to enter the clock number, wage rate, and number of hours as shown below.

The program determines both the overtime hours (anything over 40 hours) and the gross pay, and outputs the following format. Hours over 40 are paid at time and a half.

————————————————
Clock# Wage Hours OT Gross
————————————————
098401 10.60 51.0 11.0 598.90

In the example above, since the employee worked 51 hours, 11 of those hours are overtime and are paid at time and a half. The first 40 hours are paid at the standard
time using the hourly wage rate. If no overtime hours are worked, just indicate 0.0 hours in your output.

Column alignment, leading zeros in Clock#, and zero suppression in float fields are important.

With this and in future assignments, please start using constants. For example, instead of hard coding a value for 40.0, use a constant:

#define STD_HOURS 40.0

Replace 40.0 in your code with the symbolic constant STD_HOURS

There are a few other constants you should define and use for this assignment. Use at least one more constant in your homework.

Use the following data as test input:

Clock# Wage Hours 98401 10.60 51.0 526488 9.75 42.5 765349 10.50 37.0 34645 12.25 45.0 127615 8.35 0.0

Solution Preview:

#include<stdio.h>
#define STD_HOURS 40.0
#define OVERTIME_RATE 1.5

int main()
{
int datacount = 0; /* Number of test data sets */
int clockNo = 0;
float wage = 0.0;
float hours = 0.0;
float gross = 0.0; /* Variables to hold gross salaries */
float OT = 0.0; /* Variables to hold overtime */

int i = 0; /* loop counter */
printf(“Employee pay calculator\n\n”); /* Program Info */
printf(“How many employees data you wish to enter? “); /* Prompt text */
scanf(“%d”,&datacount); /* Get test data count from the user */

do
{
printf(“\nEnter Employee’s Clock #: “);
scanf(“%d”, &clockNo);
printf(“Enter hourly wage: “);
scanf(“%f”, &wage);
printf(“Enter no. of hours worked: “);
scanf(“%f”, &hours);

if (hours > STD_HOURS) // Overtime condition
{
OT = hours – STD_HOURS;
gross = (wage * STD_HOURS) + (OT * OVERTIME_RATE * wage);
}
else
{
OT = 0.00;
gross = wage * hours;
}

i++;

printf(“————————————————\n”);
printf(“%6s”,”Clock#”);
printf(“%10s”,”Wage”);
printf(“%10s”,”Hours”);
printf(“%10s”,”OT”);
printf(“%10s\n”,”Gross”);
printf(“————————————————\n”);
printf(“%06d”,clockNo);
printf(“%10.2f”,wage);
printf(“%10.1f”,hours);
printf(“%10.1f”,OT);
printf(“%10.2f\n”,gross);
printf(“\n\n”);

}while(i < datacount);
return (0);
}

 

What We Offer:

• On-time delivery guarantee
• PhD-level professionals
• Automatic plagiarism check
• 100% money-back guarantee
• 100% Privacy and Confidentiality
• High Quality custom-written papers