Computer programming in C (Not C++)
Computer programming in C (Not C++)
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 of20 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 sixstructures. (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, andgross 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 as0.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(“nID # Last Name Gross Pay”);printf(“n____ _________ _________”);
for (i = 0; i < 6; i++){info[i].Gross_Pay = ((info[i].Pay_Rate) * (info[i].Hours_Worked));printf(“n%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(“n———————————————————–“);
printf(“nThe total gross pay for all employees is %5.2f.n”, info[i].Total_Gross_Pay);
system(“pause”);return 0;}
"You need a similar assignment done from scratch? Our qualified writers will help you with a guaranteed AI-free & plagiarism-free A+ quality paper, Confidentiality, Timely delivery & Livechat/phone Support.
Discount Code: CIPD30
Click ORDER NOW..
