Question
C PROGRAM At the end of each month, a company processes payroll for its employees. The company would like to calculate the employees salaries after
C PROGRAM
At the end of each month, a company processes payroll for its employees. The company would like to calculate the employees salaries after taxes have been deducted. The data for all employees is stored in a text file. The company would like to generate a report that shows all the information for payroll.
Write a C program that reads employees numbers and monthly salaries from a text file. The program should output each employee's number, salary, taxes, and gross pay (salary after taxes). Output a summary for the total in each category. See the sample output below. The tax rate is based on the following scale:
0% for salaries below $1,000.
10% for salaries between $1,000 and $2,000.
15% for salaries of $2,000 or more.
Each line in the file contains an employee's number followed by his/her salary. Output the total salaries, total taxes, and total gross pay (use three variables to accumulate each total).
Create a data file called "payroll.txt" and include all employee data as shown in the sample data file below.
Requirements:
Write a function that calculates and returns the taxes
taxes = calculate_taxes(salary);
Write a function that outputs a single salary line to the output file
output_salary(emp_number, salary, taxes);
Write a function that outputs the summary line to the output file
output_summary(total_salaries, total_taxes);
Use a field width in your output to line up the columns: 7 for employee number and 15 for all others (left justified).
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started