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

Declare a single structure type suitable for an employee record consisting of an

ID: 3646785 • Letter: D

Question

Declare a single structure type suitable for an employee record consisting of an integer identification number, a last name (consisting of a maximum of 20 characters), a floating-point pay rate, and a floating-point number of hours worked. Using this structure type, write a C progam that interactively accepts the following data into an array of six structures:

ID Number Name Pay Rate Hours Worked

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

Once the data have been entered, the program should create a payroll report listing each name, number, and gross pay. Include the total gross pay of all employees at the end of the report.

Explanation / Answer

struct Info { int Id_Number; char Last_Name[20]; float Pay_Rate; float Hours_Worked; float Gross_Pay; float Total_Gross_Pay; }; int main(){ struct Info info[1]; int p; for (p = 0; p < 6; p++){ printf(" Enter the employee Id Number? "); scanf("%d", &info[p].Id_Number); printf(" Enter the employee Last Name? "); scanf("%s", &info[p].Last_Name); printf(" Enter the employee Pay Rate? "); scanf("%f", &info[p].Pay_Rate); printf(" Enter the employee Hours Worked? "); scanf("%f", &info[p].Hours_Worked); info[p].Gross_Pay = ((info[p].Pay_Rate) * (info[p].Hours_Worked)); } printf(" Last Name Id Number Gross Pay"); printf(" _________ _________ _________"); for (p = 0; p < 6; p++) { printf(" %-20s %-20d %2.2f", info[p].Last_Name, info[p].Id_Number, info[p].Gross_Pay); } printf(" ___________________________________________________________"); printf(" -----------------------------------------------------------"); getchar();getchar(); return 0; }
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote