Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Is there a reason why my code won't give me any calculations? Help!!! #include /* constants */ #define NUM_EMPL 5 #define OVERTIME_RATE 1.5f #define STD_WORK_WEEK

Is there a reason why my code won't give me any calculations?

Help!!!

 
 

#include

/* constants */

#define NUM_EMPL 5

#define OVERTIME_RATE 1.5f

#define STD_WORK_WEEK 40.0f

/* function prototypes */

float getHours(long int clockNumber);

float calcOvertime(float hours);

float calcGrossPay(float hours, float overtimeHrs, float wageRate);

void printHeader(void);

void printEmp(long int clockNumber, float wageRate, float hours, float overtimeHrs, float grossPay);

int main()

{

/* Variable Declarations */

long int clockNumber[NUM_EMPL] = {98401, 526488, 765349, 34645, 127615}; /* ID */

float grossPay[NUM_EMPL]; /* gross pay */

float hours[NUM_EMPL]; /* hours worked in a given week */

int i; /* loop and array index */

float overtimeHrs[NUM_EMPL]; /* overtime hours */

float wageRate[NUM_EMPL] = {10.60, 9.75, 10.50, 12.25, 8.35}; /* hourly wage rate */

/* process each employee */

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

{

/* Read in the hours for an employee */

hours[i] = getHours(clockNumber[i]);

/* calculate overtime hours */

overtimeHrs[i] = calcOvertime(hours[i]);

/* calculate gross pay */

grossPay[i] = calcGrossPay(hours[i], overtimeHrs[i], wageRate[i]);

}

/* print the header info */

printHeader();

/* print out each employee */

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

{

/* Print all the employees - call by reference */

printEmp(clockNumber[i], wageRate[i], hours[i], overtimeHrs[i], grossPay[i]);

} /* for */

return (0);

}

/* function to get hours worked from user */

float getHours(long int clockNumber)

{

float hoursWorked; /* hours worked in a given week */

/* Read in hours for employee */

printf(" Enter hours worked by emp # %06li: ", clockNumber);

scanf("%f", &hoursWorked);

/* return hours back to the calling function */

return (hoursWorked);

}

/* function to calculate overtime hours */

float calcOvertime(float hours)

{

float overtimeHrs; /* overtime hours worked in a given week */

/* determine overtime hours */

if (hours > STD_WORK_WEEK)

{

overtimeHrs = hours - STD_WORK_WEEK;

}

else

{

overtimeHrs = 0;

}

/* return overtime hours worked */

return overtimeHrs;

}

/* function to calculate gross pay */

float calcGrossPay(float hours, float overtimeHrs, float wageRate)

{

float grossPay; /* gross pay for a given week */

/* calculate gross pay */

if (hours <= STD_WORK_WEEK)

{

grossPay = hours * wageRate;

}

else

{

grossPay = STD_WORK_WEEK * wageRate + overtimeHrs * wageRate * 1.5; }

/* return gross pay */

return grossPay;

}

/* function to print header info */

void printHeader(void)

{

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

/* print the table header */

printf(" Clock# Wage Hours OT Gross ");

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

}

void printEmp(long int clockNumber, float wageRate, float hours, float overtimeHrs, float grossPay)

{

printf("%06li %5.2f %5.1f %4.1f %7.2f ", clockNumber, wageRate, hours, overtimeHrs, grossPay);

}

Success #stdin #stdout 0s 5316KB

comments ()

stdin

copy

Standard input is empty

stdout

copy

Enter hours worked by emp # 098401: Enter hours worked by emp # 526488: Enter hours worked by emp # 765349: Enter hours worked by emp # 034645: Enter hours worked by emp # 127615: *** Pay Calculator *** Clock# Wage Hours OT Gross ------------------------------------------------ 098401 10.60 0.0 0.0 0.00 526488 9.75 0.0 0.0 0.00 765349 10.50 0.0 0.0 0.00 034645 12.25 0.0 0.0 0.00 127615 8.35 0.0 0.0 0.00

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

Databases And Information Systems 1 International Baltic Conference Dbandis 2020 Tallinn Estonia June 19 2020 Proceedings

Authors: Tarmo Robal ,Hele-Mai Haav ,Jaan Penjam ,Raimundas Matulevicius

1st Edition

303057671X, 978-3030576714

Students also viewed these Databases questions

Question

Why do living creatures die? Can it be proved that they are reborn?

Answered: 1 week ago

Question

5. Our efficiency focus eliminates free time for fresh thinking.

Answered: 1 week ago