Write a program that requests the user to enter hours worked

Write a program that requests the user to enter hours worked in a week and the hourly wage. The program should then print the gross pay, the taxes, and the net pay. Assume the following:

Overtime (in excess of 40 hours for week) = time and a half.

Tax rate: 15% of the first $600, 20% of the rest.

This is what I have so far and yes I am mostly lost and have no clue.....

#include <stdio.h>

If hours = <= 40.0
Salary = hours*basepay

Else
salary = 40+basepay + (hours-40)*1.5*payrate
*/

const double max_hours = 40.0
const double multiplier = 1.5

int main()

{
double hours= 0.0;
double payrate = 0.0;

printf (\"Please enter number of hours worked: \");
scanf(\"%d\", hours);

printf(\"Please enter your hourly rate: \");
scanf(\"%d\")

double salary = 0.0

If{hours<= 40} {salary = hours*basepay;}

Else{salary = maxhours*payrate + (hours-maxhours)*multiplier*payrate;}

printf(\"Gross Pay:\")
printf(\"Tax Rate\")
printf(\"Net Pay:\")
  
return 0;
}

Solution

C program for caluculate GrossPay , Taxrate and NetPay for week.

#include<stdio.h>
int main()
{
int hwork,hwage,taxrate,tax,othour,otwage;
float salary,netpay;
printf(\"enter hours worked in a week \ \");
scanf(\"%d\",&hwork);
printf(\"enter hourly wage \ \");
scanf(\"%d\",&hwage);
if(hwork<=40)
{
salary=hwork*hwage;
if(salary<=600)
{
taxrate=15;
tax=(taxrate*salary)/100;
netpay=salary-tax;
printf(\"Gross Pay\\tTax Rate\\t Net Pay\ \");
printf(\"$ %f\\t$ %d(15%%) \\t$ %f\ \",salary,tax,netpay);
}
else
{
taxrate=20;
tax=(taxrate*salary)/100;
netpay=salary-tax;
printf(\"Gross Pay\\tTax Rate\\t Net Pay\ \");
printf(\"$ %f\\t$ %d(20%%)\\t$ %f\ \",salary,tax,netpay);
}
}
else
{
othour=hwork-40;
otwage=hwage+(hwage/2);
salary=(40*hwage)+(othour*otwage);
if(salary<=600)
{
taxrate=15;
tax=(taxrate*salary)/100;
netpay=salary-tax;
printf(\"Gross Pay\\tTax Rate\\t Net Pay\ \");
printf(\"$ %f\\t$ %d(15%%) \\t$ %f\ \",salary,tax,netpay);
}
else
{
taxrate=20;
tax=(taxrate*salary)/100;
netpay=salary-tax;
printf(\"Gross Pay\\tTax Rate\\t Net Pay\ \");
printf(\"$ %f\\t$ %d(20%%)\\t$ %f\ \",salary,tax,netpay);
}
}
return 0;
}

Sample Outputs:-

case 1: when salary <= $600

enter hours worked in a week
60
enter hourly wage
2
Gross Pay Tax Rate Net Pay
$ 140.000000 $ 21(15%) $ 119.000000

case 2: when salary >$600

enter hours worked in a week
40
enter hourly wage
20
Gross Pay Tax Rate Net Pay
$ 800.000000 $ 160(20%) $ 640.000000

Write a program that requests the user to enter hours worked in a week and the hourly wage. The program should then print the gross pay, the taxes, and the net
Write a program that requests the user to enter hours worked in a week and the hourly wage. The program should then print the gross pay, the taxes, and the net

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site