Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Intro C Programming Question: Write a C program that will calculate the gross pay of a set of employees. Unlike the first assignment, you don't

Intro C Programming Question:

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

Unlike the first assignment, you don't have to prompt for the number of employees to process up front.

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.

Example: If your hourly wage was $10 an hour, and you worked 46 hours, the first 40 hours would be your regular pay and paid at $10 an hour for a total of $400. Your overtime hours would be any hours past 40 hours, which in this case is 6 hours. To figure out the overtime pay, each of those 6 hours would paid at time and half, which would be $15 and hour (to calculate: 1.5 * $10 = $15). In this example, your standard pay would be $400 and your overtime pay would be $90 for a total gross pay of $490.

At a minimum, I would recommend at least adding a new variable to store your overtime hours. If you wish, you could optionally create variables for overtime_pay and standard_pay, that would be up to you. Students in the past have done it both ways.

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 (Hint: maybe the total number of employees to process?)

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 

Do not use any material from any chapters we have not yet covered (such as adding your own functions, arrays, structures, pointers ... we'll get to them in the future), unless we have discussed them in the lectures notes or on-line discussions.

The program should continue to query the user for how many sets of test data there are, and loop that many times. Use the code template below and modify the code as needed for this assigment.

include

int main ( )

{

int clock_num; /* employee clock number */

int numEmployees; /*number of employees */

float gross; /* gross pay for week (wage * hours) */

float hours; /* number of hours worked per week */

float wage; /* hourly wage */

int counter = 0;

/* ADD YOUR PROMPT and LOOP CODE HERE */

printf("***Pay Calculator*** ");

printf("Enter number of employees to process: "); /* Title and get number of employees to process*/

scanf("%d", &numEmployees);

/* Prompt for input values from the screen */

for(counter = 1; counter <= numEmployees; counter++)

{

printf(" Enter Employee's Clock #: ");

scanf ("%d", &clock_num);

printf("Enter hourly wage: ");

scanf ("%f", &wage);

printf("Enter number of hours worked: ");

scanf ("%f", &hours);

/* calculate gross pay */

gross = wage * hours;

/* print out employee information */

printf(" ----------------------------------------- ");

printf("Clock# Wage Hours Gross ");

printf("----------------------------------------- ");

printf ("%06i %5.2f %5.1f %7.2f ",clock_num, wage, hours, gross);

/* END YOUR LOOP HERE */

}

return (0); /* success */

} /* main */

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

Essentials of Database Management

Authors: Jeffrey A. Hoffer, Heikki Topi, Ramesh Venkataraman

1st edition

133405680, 9780133547702 , 978-0133405682

More Books

Students also viewed these Databases questions

Question

When can res ipsa loquitor be applied?

Answered: 1 week ago

Question

4. Show the trainees how to do it again.

Answered: 1 week ago