Update the first program. Use a for loop to process the data for 5employees. Upd
ID: 3619094 • Letter: U
Question
Update the first program. Use a for loop to process the data for 5employees. Update the output as shown in the sample data. Usearrays to store the variable data. In the for loop, if any of theentered fields are –1, break out of the loop.Example (Sample input & output for one person)
Enter name: Glenn
Enter hourly rate: 2.00
Enter hours worked: 50
Pay to: Glenn
Hours worked: 50.0
Hourly rate: $ 2.00
Gross pay: $110.00
Base pay: $ 80.00
Overtime pay: $ 30.00
Taxes paid: $ 22.00
Net pay: $ 88.00
------------------
1st program:
#include <stdio.h>
#include <conio.h>
int main()
{int i;
double rate, hours, tax, salary,paid;
char name[10];
for(i=0;i<5;i++)
{printf("Enter name: ");
scanf("%s",&name);
printf("Enter hourly rate: ");
scanf("%lf",&rate);
printf("Enter hours worked: ");
scanf("%lf",&hours);
printf("Pay to: %s ",name);
printf("Hourly rate: %.2f ",rate);
printf("Hours worked: %.2f ",hours);
if(hours>40)
{salary=rate*40;
hours-=40;
salary=salary+(hours*(rate*1.5));
}
else
salary=hours*rate;
tax=salary*.2;
paid=salary-tax;
printf("Salary before taxes:$%.2f ",salary);
printf("Taxes paid: $%.2f ",tax);
printf("Amount paid: $%.2f ",paid);
}
getch();
return 0;
}
Explanation / Answer
please rate - thanks as per your message exact, except for the spaces between the lines. I didn't putthose since often when code is pasted into cramster blank linesappear, so I didn't know if you wanted them or not. In addition Iline all the columns up, that can be removed. if any problemmessage me, before rating, I can fix it #include #include #include int main() {int i,j; double rate[5], hours[5], tax[5],salary[5],paid[5],overtime[5],base[5]; char name[5][10]; for(i=0;i40) {base[i]=rate[i]*40; overtime[i]=(hours[i]-40)*rate[i]*1.5; } else {base[i]=hours[i]*rate[i]; overtime[i]=0; } salary[i]=base[i]+overtime[i]; tax[i]=salary[i]*.2; paid[i]=salary[i]-tax[i]; } printf(" "); for(j=0;jRelated 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.