Create a payroll program to store and calculate the payroll for a small company with a maximum of 20 employees.
Program parameters are as follows:
1. Create a menu with the following options (use a do-while loop):
A or a to add employee info
D or d to display employee info
T or t to display total payroll
S or s to display the info of all employees
Z or z to exit program
The information for each employee is: employee number, hours worked, pay rate per hour, tax deduction.
2. Use an array of doubles to store employee information.
3. Menu option A or a: ask the user for the employee information one value at . a time and store it in the array.
Please enter employee number: 2190
Please enter hours worked: 32.50
Please enter pay rate: 9.25
Please enter tax rate deduction: 5.50
4. Option D or d: ask the user for an employee number as integer and display . the information for the corresponding employee (cast the employee number
. in the array to integer and then compare). If employee number does not
. match, output a msg. indicating “no such employee”. If the employee number . is a match, output all the employee information stored in addition to the . calculated deduction and salary.
Output sample:
Info for employee number: 2190
Hours worked: 32.50
Pay rate: $ 9.25
Tax deduction: 5.50 %
Total pay: $ 284.89
5. Option T or t: calculate and output the sum of the total pay of all
. employees.
6. Option S or s: display the information for all employees in the same
. format as in option B.
7. Option Z or z: exit the program.
#include <stdio.h>
#define MAX [20]
int main(void)
{
int i;
for (i=0;i<=20;i++)
{
char MenuOption=0;
int EmployeeNumber;
double Hours;
double Pay;
double Tax;
double EmployeeTotalPay;
double TotalPayroll;
printf("Menu option Information Type\n");
printf("A= Add Employee Information\n");
printf("D= Display Employee Information\n");
printf("T= Display Total Payroll\n");
printf("S= Display Information For All Employees\n");
printf("Z= Exit Program\n\n");
printf("Please enter the letter of the Menu Option for the Operation you wish to perform.\nThen press enter:\n");
scanf(" %c",&MenuOption);
switch (MenuOption)
{
case 'Z': case 'z':
printf("You have chosen to Exit the program.\nGood-Bye.");
return 0;
case 'A': case 'a':
printf ("Enter the employees Employee Number:\n");
scanf("%lf", &EmployeeNumber);
printf("Please input the employee's number of hours worked: ");
scanf(" %lf",&Hours);
printf("Please input the employee's hourly pay rate: ");
scanf(" %lf",&Pay);
printf("Please input the employee's tax rate deduction as a decimal(i.e.: %% 5.50 = .0550: ");
scanf(" %lf",&Tax);
printf("Employee Number: %ld\nHours worked: %.2f\nPay rate: $ %.2f\nTax Rate Deduction: %.4f %\nTotal Pay: $ %.2f\n\n\n",EmployeeNumber,Hours,Pay,Tax,Hours*Pay-Hours*Pay*Tax);
printf("Please input the employee's Total Pay as a decimal,\n(i.e.: $430.25 = 430.25) for storage in the payroll database: ");
scanf(" %.2lf",&EmployeeTotalPay);
printf(" %.2lf",TotalPayroll);
return;
break;
}
return 0;
}
}