if you enter in 40 or less for the hour it works perfectly fine. As soon as it start calculating overtime time pay it messes up...
any help would be appreciated.
Code:
#include <stdio.h>
int hours; /*hours worked*/
int pay1; /*hourly wage*/
int pay2; /*overtime pay (1.5 the pay1)*/
int overtime; /*amount acounted with overtime hours*/
int main(int argc, const char * argv[]) {
printf("Enter in the amount of hours you've worked this week");
scanf("%d", &hours);
int overtimepay;
pay1 = (hours * 9);
pay2 = 9 + (9 / 2);
overtimepay = (hours - 40) * pay2;
overtime = pay1 + overtimepay;
if (hours <= 40)
{
printf("Your weekly pay is %d\n", pay1);
}
else
{
printf("Your weekly pay is %d\n", overtime);
}
return 0;
}