In: Computer Science
Write a C program that calculates a worker’s wages from their hours worked and hourly rate. This wage calculator should also account for overtime hours, calculate amount to be witheld from taxes, and calculate the final net income. Required functionality: 1. Ask the user for the number of hours worked and hourly rate in dollars. The program should be able to accept decimal values for both of these (e.g. 3.2 hours, 11.25 dollars/hour) 2. Overtime hours are those worked in excess of 40 hours per week. Overtime hours are billed at 1.5 times the hourly rate. 3. The taxes to be withheld from the user’s net income should be calculated. The tax rate is 15%. 4. Final net income should be calculated as: net income = normal income + overtime income – taxes withheld where normal income is the amount earned on the first 40 hours of work and overtime income the amount earned on all hours over 40. 5. All information should be printed to the screen in a nicely formated manner and look very close to the following example
my calculations are wrong on this. can anyone help out?
Answer to above question:
#include<stdio.h>
float cal_tax(float bill)
{
float tax = 0.0;
tax = (bill * 15)/100;
return tax;
}
float final_income(float normal_inc,float OT,float tax)
{
float net_income =0.0;
net_income = normal_inc+OT-tax;
return net_income;
}
float over_time(float hours,float rate)
{
float bill =0.0;
float excess_hours = hours - 40;
bill = (excess_hours * 1.5 *
rate) + 40 * rate;
return bill;
}
float normal_income(float hours,float rate)
{
float bill =0.0;
bill = hours * rate;
return bill;
}
int main()
{
float hours1 = 0.0, rate1 = 0.0, n_i =0.0, o_t=0.0,
tax1=0.0,tax2=0.0;
printf("Number of Hours Worked\n");
scanf("%f",&hours1);
printf("Enter Hour Rate\n");
scanf("%f",&rate1);
n_i=normal_income(hours1,rate1);
o_t = over_time(hours1,rate1);
tax2 = n_i+o_t;
tax1=cal_tax(tax2);
printf("Final Income
%f\n",final_income(n_i,o_t,tax2));
return 0;
}