Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need some help my code is not calculating not displaying first and last name o

ID: 3639065 • Letter: I

Question

I need some help my code is not calculating not displaying first and last name of the employee. I tried everything the only thing that work is scanf but its only printing the first name.

Category
Description of Violation
# Points Deducted

Comments:
No block comment at beginning of program/your name not in comment.
-10


Vague, non-descriptive comments.
-2 for each


No block comments in code.
-10





Variables:
Non-descriptive variable names
(except for loop-control variables.)
-3 for each


Variables declared, but not used.
-3 for each


Unnecessary initialization of variables during declaration.
-3 for each


Global Variables - DO NOT USE
-10 for each


goto statements - DO NOT USE
-10 for each


Inefficient code (subjectively determined by instructor)
-5 for each





Indentation:
Not following indentation standards.
-3 for each


Inconsistent indentation.
-3 for each


Block Marker alignment (i.e. not same indent for begin/end markers { and })
-3 for each





Correctness:
Program does not produce correct results.
-5 to -15


Prompts not formatted as assigned.
-2 to -15


Program output not formatted as assigned.
-2 to -15


Miscellaneous - at the instructors discretion
-3 to -10 for each


Use of // comments – Avoid
-2 for each

Misc:
goto statements - DO NOT USE
-10 for each


Inefficient Code
-5 for each


Other (at instructors discretion).
-1 to -10


Program does not conform to ANSI standards
-10


Program uses statements not yet introduced
-5 for each occurrence


Use fflush(stdin); after each scanf
-2 for each not used


Misc. mistakes: not following instructions, program naming, etc.
-2 to -10 each




Late Assignments
-5 first day then

-1 per day afterwards










Write a C program that determines the gross pay and net pay for each of n employees, then prints out a payroll summary report. For each employee, your program should prompt for the number of hours worked and the hourly rate of the worker. Once this information is entered, your program should calculate the gross pay, federal tax paid, and net pay for that employee.

Gross pay is calculated by: hours worked * hourly rate, plus overtime pay, if any. The company pays “straight-time” for the first 40 hours worked by each employee, and pays “time-and-a-half” for all hours worked in excess of 40 hours.

Your program should include at least three functions. One of which is called to determine the overtime pay. It would require 2 parameters passed to it (hourly rate, and hours worked), both of which are data type float. It would return the calculated overtime pay (as shown below), which is of data type float. This function should only be called if necessary (that is, when the number of hours worked is more than 40.0).

The second function should be called to calculate the federal tax. It requires 1 parameter passed to it (gross pay), and should return the federal tax paid, both of which should be data type float. Assume that federal tax is 20% of gross pay (as shown below).

The net pay can then be calculated (gross pay - federal tax) in a third function.

Use the following calculations in your functions:

overtime pay = (hours worked - 40.0) * hourly rate * 1.5

federal tax = gross pay * .2

The dialog with the user must be as follows: (the welcome message can be designed of your own chosing)

Welcome to the Payroll Calculator

Enter the number of employees(1-10): 3


Enter the name for employee 1: John Smith
Enter the number of hours for John Smith: 40
Enter the hourly rate for John Smith: 10.00

Enter the name for employee 2: Jane Doe
Enter the number of hours for Jane Doe: 41
Enter the hourly rate for Jane Doe: 20.00

Enter the name for employee 3: Dick Sally
Enter the number of hours for Dick Sally: 36
Enter the hourly rate for Dick Sally: 15.20

Payroll Report
--------------------

John Smith

Gross Pay: $ 400.00
Federal Tax: $ 80.00
Net Pay: $ 320.00

Jane Doe

Gross Pay: $ 830.00
Federal Tax: $ 166.00
Net Pay: $ 664.00

Dick Sally

Gross Pay: $ 547.20
Federal Tax: $ 109.44
Net Pay: $ 437.76

Report Totals
-------------------

Gross Pay: $ 1777.20
Federal Tax: $ 355.44
Net Pay: $ 1421.76




#include<stdio.h>

void safer_geats(char array[], int max_chars)
{
float getOvertimePay();
float getFederalTax ();
float getgross_pay();
float getnetpay();
}

main()


{
float hours_worked, hourly_rate, gross_pay[10], overtime_pay, federal_tax[10];
float net_pay;
int x, num;
char first_last[10][30] = {" "};

printf("Welcome to the Payroll Calculator ");
printf("Enter the number of employees(1 - 10): ");
scanf("%i", &num);

printf(" ");
for(x = 0; x < num; ++x)
{
printf(" Enter the name for employee %i: ", x + 1);
scanf("%s", &first_last);
fflush(stdin);

printf("Enter the number of hours for %s: ", first_last);
scanf("%i", &hours_worked);
fflush(stdin);

printf("Enter the hourly rate for %s: ", first_last);
scanf("%i", &hourly_rate);
fflush(stdin);

if(hours_worked <= 40)
{
overtime_pay = gross_pay[10] * hours_worked * hourly_rate;
gross_pay[10] = hours_worked * hourly_rate;
}

else if(hours_worked > 40)
{

gross_pay[10] = 40 * hours_worked + (hourly_rate - 40) * hourly_rate * 1.5;
}/* End if loop */

}/* End for loop */

printf("Payroll Report ");
printf("---------------");

for(x = 0; x < num; ++x)
{

printf("%s ", first_last[x + 1]);
printf("Gross: $ %15.2f ", x + 1);
printf("Federal Tax: $ %15.2f ", x + 1);
printf("Net Pay: $ %15.2f ", x + 1);
}



getchar();
}

Explanation / Answer

as promised

please rate - thanks

message me before rating if any problems

sample run

#include<stdio.h>

float getOvertimePay(float,float);
float getFederalTax (float);
float getgross_pay(float,float);
float getnetpay(float,float);


main()


{
float hours_worked, hourly_rate, gross_pay[10], overtime_pay, federal_tax[10];
float net_pay[10],total_gross=0,total_tax=0,total_net=0;
int x, num;
char first_last[10][30] = {" "};

printf("Welcome to the Payroll Calculator ");
printf("Enter the number of employees(1 - 10): ");
scanf("%i", &num);

printf(" ");
for(x = 0; x < num; ++x)
{fflush(stdin);
printf(" Enter the name for employee %i: ", x + 1);
gets(first_last[x]);

printf("Enter the number of hours for %s: ", first_last[x]);
scanf("%f", &hours_worked);

printf("Enter the hourly rate for %s: ", first_last[x]);
scanf("%f", &hourly_rate);

if(hours_worked<=40)
     gross_pay[x]=getgross_pay(hours_worked,hourly_rate);
else
    {gross_pay[x]=getgross_pay(40,hourly_rate);
      overtime_pay= getOvertimePay(hours_worked-40.,hourly_rate);
      gross_pay[x]+=overtime_pay;
     }
federal_tax[x]=getFederalTax (gross_pay[x]);
net_pay[x]=getnetpay(gross_pay[x],federal_tax[x]);
total_gross+=gross_pay[x];
total_tax+=federal_tax[x];
total_net+=net_pay[x];
}/* End for loop */
printf(" Payroll Report ");
printf("--------------- ");
for(x = 0; x < num; ++x)
{
printf("%s ", first_last[x]);
printf("Gross Pay: $ %5.2f ",gross_pay[x]);
printf("Federal Tax: $ %5.2f ",federal_tax[x]);
printf("Net Pay: $ %5.2f ", net_pay[x]);
}
printf(" Payroll Report ");
printf("--------------- ");
printf("Gross Pay: $ %5.2f ",total_gross);
printf("Federal Tax: $ %5.2f ",total_tax);
printf("Net Pay: $ %5.2f ", total_net);
fflush(stdin);
getchar();
}
float getOvertimePay(float hours,float rate)
{ return hours*rate*1.5;
      }
float getFederalTax (float pay)
{return pay*.2;
}
float getgross_pay(float time,float rate)
{return time*rate;
}
float getnetpay(float gross,float tax)
{return gross-tax;
      }