The question reads: \"Declare a single structure type suitable for an employee r
ID: 3646969 • Letter: T
Question
The question reads: "Declare a single structure type suitable for an employee record consisting of an integer identificatin number, a last name (consisting of a max of 20 characters), a floating-point pay rate, and a floating-point number of hours worked. Write a C program that interactively accepts the data into an array of six structures. (The data is hard coded already). Once the data have been entered, the program should create a payroll report listing each employee's name, number, and gross pay. Include the total gross pay of all employees at the end of the report."This is what I have so far, and it compiles and everything, but it won't calculate a number for the gross pay. Have I entered something wrong? It just comes out as 0.00.
#include <stdio.h>
struct Info
{
int Id_Number;
char Last_Name[20];
float Pay_Rate;
float Hours_Worked;
float Gross_Pay;
float Total_Gross_Pay;
};
int main()
{
int i;
struct Info info[6] = {{3462, "Jones", 4.62, 40.0},
{6793, "Robbins", 5.83, 38.5},
{6985, "Smith", 5.22, 45.5},
{7834, "Swain", 6.89, 40.0},
{8867, "Timmins", 6.43, 35.5},
{9002, "Williams", 4.75, 42.0}
};
info[i].Total_Gross_Pay = 0;
printf(" ID # Last Name Gross Pay");
printf(" ____ _________ _________");
for (i = 0; i < 6; i++)
{
info[i].Gross_Pay = ((info[i].Pay_Rate) * (info[i].Hours_Worked));
printf(" %d %-10s %5.2f", info[i].Id_Number, info[i].Last_Name, info[i].Gross_Pay);
info[i].Total_Gross_Pay = (info[i].Total_Gross_Pay + info[i].Gross_Pay);
}
printf(" -----------------------------------------------------------");
printf(" The total gross pay for all employees is %5.2f. ", info[i].Total_Gross_Pay);
system("pause");
return 0;
}
Explanation / Answer
please check your program you have already written info[i].Total_Gross_Pay = 0; gross payment=0 also after struct Info { int Id_Number; char Last_Name[20]; float Pay_Rate; float Hours_Worked; float Gross_Pay; float Total_Gross_Pay; }; write int i; for (i = 0; i< 6; i++)Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.