Question

Create a payroll program named CalcPay that allows the user to enter two double valuesand a...

  1. Create a payroll program named CalcPay that allows the user to enter two double valuesand a string namely hours worked, hourly rate and name. After the user enters the rate, hours,and name the program should calculate the gross pay. Compute federal withholding tax which is subtracted from gross based on the following table: Hints: (100pts) Use methods as deemed appropriate. 0 to 99.99 6% 100.00 to 299.99 12% 300.00 to 599.99 18% 600.00 and up 21%. Display the output. The display should include: Name, hours, rate, deduct, gross and net. You should also display the same using printf. Submit the program as an attachment
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer:

Code:

#include <stdio.h>
#include <stdlib.h>
int main()
{
// Declaring variable
int i;
double hoursWorked, hourlyRate, grosspay, federal, net;
char name[50];

printf("Enter name :");
scanf("%s", name);

printf("Enter no of hours worked :");
scanf("%lf", &hoursWorked);

printf("Enter hourly rate :");
scanf("%lf", &hourlyRate);

grosspay = hoursWorked * hourlyRate;

if (grosspay >= 0 && grosspay <= 99.99)
{
federal = 0.06 * grosspay;
}
else if (grosspay >= 100 && grosspay <= 299.99)
{
federal = 0.12 * grosspay;
}
else if (grosspay >= 300.00 && grosspay <= 599.99)
{
federal = 0.18 * grosspay;
}
else if (grosspay >= 600)
{
federal = 0.21 * grosspay;
}

net = grosspay - federal;

FILE* f1;
// Opening the output file in write mode
f1 = fopen("Payout.txt", "w");
if (f1 == NULL)
{
printf("Error!");
exit(1);
}
// writing the odd numbers between 1-100

fprintf(f1, "Name = %s\n", name);
fprintf(f1, "No of of worked hours = %.2lf\n", hoursWorked);
fprintf(f1, "Pay Rate = %.2lf\n", hourlyRate);
fprintf(f1, "Deduct = %.2lf\n", federal);
fprintf(f1, "Gross = %.2lf\n", grosspay);
fprintf(f1, "Net = %.2lf\n", net);


// closing the output file
fclose(f1);

return 0;
}

Output:

Payout.txt

Add a comment
Know the answer?
Add Answer to:
Create a payroll program named CalcPay that allows the user to enter two double valuesand a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Create a payroll program named CalcPay that allows the user to enter two double valuesand a...

    Create a payroll program named CalcPay that allows the user to enter two double valuesand a string namely hours worked, hourly rate and name. After the user enters the rate, hours,and name the program should calculate the gross pay. Compute federal withholding tax which is subtracted from gross based on the following table: Hints: (100pts) Use methods as deemed appropriate. 0 to 99.99 6% 100.00 to 299.99 12% 300.00 to 599.99 18% 600.00 and up 21%. Display the output. The...

  • Create an applet payroll program named CalcPay that allows the user to enter two double valuesand...

    Create an applet payroll program named CalcPay that allows the user to enter two double valuesand a string namely hours worked, hourly rate and name. After the user enters the rate, hours,and name the program should calculate the gross pay by pressing CALCULATE button. Compute federal withholding tax which is subtracted from gross based on the following table: Hints: (100pts) Use methods as deemed appropriate. 0 to 99.99 6% 100.00 to 299.99 12% 300.00 to 599.99 18% 600.00 and up...

  • use at least two functions in your program. . Write a program that calculates weekly payment....

    use at least two functions in your program. . Write a program that calculates weekly payment. The program will ask the user full name, ID number (make one up), and hours worked. An hourly worker’s gross pay is basically his/her work hours that week multiplied by his/her regular hourly pay rate. However, after the first 40 work hours of the week, each additional work hour is paid at an overtime rate that is 1.5 times of the regular hourly rate....

  • ASAP Please. Python Program Description Create an object-oriented program that allows you to enter data for...

    ASAP Please. Python Program Description Create an object-oriented program that allows you to enter data for employees. Specifications Create an abstract Employee class that provides private attributes for the first name, last name, email address, and social security number. This class should provide functions that set and return the employee’s first name, last name, email address, and social security number. This class has a function: get_net_income which returns 0. Create a Manager class that inherits the Employee class. This class...

  • Styles Program Description Write a C++ program that computes and displays employees' earnings. Prompt the user...

    Styles Program Description Write a C++ program that computes and displays employees' earnings. Prompt the user for type of employee (hourly ("h"or "H") or management ("'m" or "M") If the employee is management: . get the annual salary get the pay period (weekly ("w" or "W"), bi-weekly ("b" or "B") or monthly ("m" or e compute the gross salary for the pay period (Divide annual salary by 52 for weekly, 26 for bi-weekly, and 12 for monthly) deduct from gross...

  • You are to write a program that will process employees and their pay. For each employee...

    You are to write a program that will process employees and their pay. For each employee the program will read in an employee’s name and hourly pay rate. It should also read in the number of hours worked each day for 5 days and calculate his or her total number of hours worked. You must read the hours using a loop. The program should output the employee’s name, gross pay, total withholding amount and net pay. Withholding is made up...

  • C++ Program The Ward Bus Manufacturing Company has recently hired you to help them convert their...

    C++ Program The Ward Bus Manufacturing Company has recently hired you to help them convert their manual payroll system to a computer-based system. Write a program to produce a 1-week payroll report for only one employee to serve as a prototype (model) for the administration to review. Input for the system will be the employee’s 4-digit ID number, the employee’s name, hours worked that week, and the employee’s hourly pay rate. Output should consist of the employee’s ID number, the...

  • It's my python assignment. Thank you You wrote a program to prompt the user for hours...

    It's my python assignment. Thank you You wrote a program to prompt the user for hours and rate per hour to compute gross pay. Also your pay computation to give the employee 1.5 times the hourly rate for hours worked above 40 hours. Enter Hours: 45 Enter Rate: 10 Pay: 475.0 (475 = 40 * 10 + 5 * 15) Rewrite your pay program using try and except so that your program handles non-numeric input gracefully. Enter Hours: 20 Enter...

  • Create a Java file named Ch6Asg.java that contains a public class named Ch6Asg containing a main()...

    Create a Java file named Ch6Asg.java that contains a public class named Ch6Asg containing a main() method. Within the same file, create another class named Employee, and do not declare it public. Create a field for each of the following pieces of information: employee name, employee number, hourly pay rate, and overtime rate. Create accessor and mutator methods for each field. The mutator method for the hourly pay rate should require the value to be greater than zero. If it...

  • The Excel file Payroll Data provides hourly salaries for a group of employees. Create an Excel...

    The Excel file Payroll Data provides hourly salaries for a group of employees. Create an Excel template that allows the user to select an employee by employee ID, enter the number of regular hours and overtime hours worked, and display a payroll summary with the employee name, gross pay, federal tax, state tax, Social Security, Medicare withholding deductions, and net pay. Assume that the federal tax rate is 11%, the state tax rate is 2.385%, Social Security withholding is 6.2%,...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT