Question: Using my code written below on the bottom, I'm supposed to reconstruct the code using defined functions with input and returns values in programming language
Using my code written below on the bottom, I'm supposed to reconstruct the code using defined functions with input and returns values in programming language C.
Here is what's required with the defined functions to help reconstruct the code:
Requirements for Computing Gross Pay The logic to compute bonus pay must be located in a function with the following requirements: Function name: computeGrossPay Parameters: wage (double), number of hours worked (int), overload multiplier (int) (double) Return value: gross pay (double) Note: The overload multiplier will be 2 for welders or 1.5 for all other employees.
Requirements for Computing Taxes and Medical The logic to compute hourly pay must be located in a function with the following requirements: Function name: computeTaxMed Parameters: gross pay (double), tax and medical deduction rate (double) Return value: tax and medical deductions (double) Note: The tax and medical deduction rate will be a parameter that is always 0.03 0.3 in this assignment.
Requirements for Computing the Union Dues The logic to compute deduction must be located in a function with the following requirements: Function name: computeUnionDues Parameters: hourly wage (double) Return value: union dues (double)
Requirements for Computing the Paycheck Amount The logic to compute deduction must be located in a function with the following requirements: Function name: computePaycheckAmount Parameters: gross pay (double), taxes and medical (double), union dues (double) Return value: paycheck amount (double)
-----------------------------------------
#include int main() { float hourlywage, hoursworked, overtime, overtimepay, regularpay, totalpay, otearnings, overtimehours, tandm, uniondues, paycheck, totalpay2, paycheck2; char ch; // for choice yes or no printf("Is the employee a welder(Y/N)?>"); printf(" "); scanf("%c", & ch); printf("Enter hourly wage>"); printf(" "); scanf("%f", & hourlywage); printf("Enter hours worked>"); printf(" "); scanf("%f", & hoursworked); printf(" ");
if (ch == 'y' || ch == 'Y') { if (hoursworked > 40) { //Calculations overtimehours = (hoursworked - 40); overtimepay = (hourlywage * 2); regularpay = (40 * hourlywage); otearnings = (overtimepay * overtimehours); totalpay = (regularpay + otearnings); tandm = (totalpay * .30); uniondues = (hourlywage * 2.5 / 4); paycheck = (totalpay - tandm - uniondues);
//Print output statements printf("Grosspay "); printf("%.2f ", totalpay);
printf("Taxes/medical "); printf("%.2f ", tandm);
printf("Union dues "); printf("%.2f ", uniondues);
printf("Paycheck "); printf("%.2f ", paycheck); } else if (hoursworked <= 40) { //Calculations totalpay2 = (hourlywage * hoursworked); tandm = (totalpay2 * .30); uniondues = (hourlywage * 2.5 / 4); paycheck2 = (totalpay2 - tandm - uniondues);
//Print output statements printf("Grosspay "); printf("%.2f ", totalpay2);
printf("Taxes/medical "); printf("%.2f ", tandm);
printf("Union dues "); printf("%.2f ", uniondues);
printf("Paycheck "); printf("%.2f ", paycheck2); } } //End of 'Y' check else if (ch == 'n' || ch == 'N') { if (hoursworked > 40) { //Calculations overtimehours = (hoursworked - 40); overtimepay = (hourlywage * 1.5); regularpay = (40 * hourlywage); otearnings = (overtimepay * overtimehours); totalpay = (regularpay + otearnings); tandm = (totalpay * .30); uniondues = (hourlywage * 2.5 / 4); paycheck = (totalpay - tandm);
//Print output statements printf("Grosspay "); printf("%.2f ", totalpay);
printf("Taxes/medical "); printf("%.2f ", tandm);
printf("Paycheck "); printf("%.2f ", paycheck); } else if (hoursworked <= 40) { //Calculations totalpay2 = (hourlywage * hoursworked); tandm = (totalpay2 * .30); paycheck2 = (totalpay2 - tandm);
//Print output statements printf("Grosspay "); printf("%.2f ", totalpay2);
printf("Taxes/medical "); printf("%.2f ", tandm);
printf("Paycheck "); printf("%.2f ", paycheck2); } } //End of 'N' check
return (0);
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
