CODE
* Filename: C8PAY2.C
Compute the full overtime pay possibilities */
#include <stdio.h>
main()
{
int hours;
float dt, ht, rp, rate, pay;
printf("\n\nHow many hours were worked? ");
// Enter whole numbers only
scanf(" %d", &hours);
printf("\nWhat is the regular hourly pay?");
scanf(" %f", &rate);
/* Compute pay here */
/* Double-time possibility */
if (hours > 50)
{ dt = 2.0 * rate * (float)(hours - 50);
ht = 1.5 * rate * 10.0; } // Time + 1/2 for 10 hours
else
{ dt = 0.0; } // Either none or double for those hours over 50
/* Time and a half */
if ((hours > 40) && (hours <= 50))
{ ht = 1.5 * rate * (float)(hours - 40); }
/* Regular Pay */
if (hours >= 40)
{ rp = 40 * rate; }
else
{ rp = (float)hours * rate; }
pay = dt + ht + rp; // Add up 3 components of payroll
printf("\nThe pay is %.2f", pay);
getch();
return 0;
}
Compute the full overtime pay possibilities */
#include <stdio.h>
main()
{
int hours;
float dt, ht, rp, rate, pay;
printf("\n\nHow many hours were worked? ");
// Enter whole numbers only
scanf(" %d", &hours);
printf("\nWhat is the regular hourly pay?");
scanf(" %f", &rate);
/* Compute pay here */
/* Double-time possibility */
if (hours > 50)
{ dt = 2.0 * rate * (float)(hours - 50);
ht = 1.5 * rate * 10.0; } // Time + 1/2 for 10 hours
else
{ dt = 0.0; } // Either none or double for those hours over 50
/* Time and a half */
if ((hours > 40) && (hours <= 50))
{ ht = 1.5 * rate * (float)(hours - 40); }
/* Regular Pay */
if (hours >= 40)
{ rp = 40 * rate; }
else
{ rp = (float)hours * rate; }
pay = dt + ht + rp; // Add up 3 components of payroll
printf("\nThe pay is %.2f", pay);
getch();
return 0;
}
Някои може ли да ми я обясни.