fork download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4.  
  5. int hoursWorked;
  6. double hourlyRate;
  7. double salary;
  8. printf("%s", "Enter # of hours worked (-1 to end): ");
  9. scanf("%d",&hoursWorked);
  10.  
  11. while (hoursWorked != -1)
  12. {
  13. printf("%s", "Enter hourly rate of the worker ($00.00): ");
  14. scanf("%lf",&hourlyRate);
  15. if (hoursWorked <= 40)
  16. {
  17. salary = hoursWorked * hourlyRate;
  18. }
  19. else
  20. {
  21. salary = 40 * hourlyRate + (hoursWorked - 40) * hourlyRate * 1.5;
  22. }
  23. printf("Salary is: $%.2f\n", salary);
  24. puts("");
  25. printf("%s", "Enter # of hours worked (-1 to end): ");
  26. scanf("%d", &hoursWorked);
  27. }
  28. }
  29.  
Success #stdin #stdout 0s 5320KB
stdin
39
10
-1
stdout
Enter # of hours worked (-1 to end): Enter hourly rate of the worker ($00.00): Salary is: $390.00

Enter # of hours worked (-1 to end):