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....

  • (Java) HELP! Create a program that will ask the user to enter their first name and...

    (Java) HELP! Create a program that will ask the user to enter their first name and their favorite number. Ask the user if they would like the information repeated back to them. If they type "Y" display the answers back to them. If they type anything else, display the word "Goodbye". An example of what your output window should look like is below. The system-generated output is in red. The user-provided input is in green. (Your actual program will only...

  • 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...

  • Questions:(to be answered within the video) Write a C++ program with the following specifications: 1. Create...

    Questions:(to be answered within the video) Write a C++ program with the following specifications: 1. Create a class and name it Payslip. This class should have the following attributes or properties: name,pay grade, basic salary, overtime hours, overtime pay, gross pay, net pay and withholding tax. 2. Define the accessors and mutators of the Payslip class based on its attributes or properties.  This class should also have the following methods: determinePayGradeAndTaxRate and computePay. 3. Create another class and name it Employee.  This...

  • 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...

  • Write a program to prompt the user for hours and rate per hour using input to...

    Write a program to prompt the user for hours and rate per hour using input to compute gross pay. Pay should be the normal rate for hours up to 40 and time-and-a-half for the hourly rate for all hours worked above 40 hours. Put the logic to do the computation of pay in a function called computepay() and use the function to do the computation. The function should return a value. Use 45 hours and a rate of 10.50 per...

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