Code:
#include "stdio.h"
#define YES 1
#define NO 0 // not used
int main()
{
int num_employees = 0, response;
double wage_rate, hours_worked, weekly_pay = 0, total_weekly_pay = 0;
while(true){
// Process an employee?
printf("\nDo you want to process an employee?[1/0] ");
scanf("%d", &response);
if(response == YES){
// wage rate?
printf("\nWage rate for current employee: $");
scanf("%lf", &wage_rate);
// hours worked?
printf("Number of hours worked: ");
scanf("%lf", &hours_worked);
// calculate/display
weekly_pay = wage_rate * hours_worked;
printf("Weekly pay for current employee: $%.2f\n",weekly_pay);
total_weekly_pay += weekly_pay; num_employees++;
}
else
break;
}
// display total pay for all employees
printf("\nThe Total Weekly Pay for %d employees is $%.2f\n\n",
num_employees, total_weekly_pay);
return 0;
}
try it.