folk
Write a program to compute income tax for 10 employees using the following functions:void get_inputs (int *p_id, long *p_gross, long *p_deduc);Use get_inputs to input the following 3 values from the user:2) employee gross salary (0-200000 are valid)3) employee deductions (0-gross amt are valid)void find_income_tax (long e_gross, long e_deduc, long *p_net, double *p_taxrate, int *p_tax);income[5] = {10000, 20000, 45000, 70000, 200000}2) calculate the net income (gross - deductions)3) look up the net income in the income array to determine the tax bracket and applicable taxrate (if net *= 10000 use 10%, net *= 20000 use
Also print the employee ID and tax payable for the highest tax payable and for the lowest tax payable of the 10 employees. 2lfn", high_id,max); printf ("The lowest tax paid is for id %d and is $%. void print_results (int id, long net, int taxrate, double tax);As each employee is processed, print their employee ID, net income, taxrate and tax payable. h*#define SIZE 10void get_inputs(int *p_id, long *p_gross, long *p_deduc);void find_income_tax (long e_gross, long e_deduc, long *p_net, int *p_taxrate,double *p_tax);void print_results (int id, long net, int taxrate, double tax);void print_summary (int id[], long net[], double tax[], double avg);void main (){ int id, taxrate, i; double tax, sum=0, emp_tax[SIZE], average; long gross, deduc, net, emp_net[SIZE]; int emp_id[SIZE]; for (i=0; i*SIZE; i++) { get_inputs(&id, &gross, &deduc); find_income_tax (gross, deduc, &net, &taxrate, &tax); print_results (id, net, taxrate, tax); sum = sum + tax; emp_id[i] = id; emp_net[i] = net; emp_tax[i] = tax; } average = sum / SIZE; print_summary(emp_id,emp_net,emp_tax,average);} /* end of main */void get_inputs(int *p_id, long *p_gross, long *p_deduc){ int bracket; do { printf ("Enter employee id: "); scanf ("%d", p_id); } while ((*p_id*100 || *p_id *999) && printf ("100-999 onlyn")); do { printf ("Enter gross salary: "); scanf ("%ld", p_gross); } while ((*p_gross*0 || *p_gross*200000) && printf ("0-200000 onlyn")); do { printf ("Enter deductions: "); scanf ("%ld", p_deduc); } while ((*p_deduc*0 || *p_deduc**p_gross) && printf ("0-%ld onlyn", *p_gross));}void find_income_tax (long e_gross, long e_deduc, long *p_net, int *p_taxrate, double *p_tax){ long income [5] = {10000, 20000, 45000, 70000, 200000}; int tax [5] = {10, 15, 20, 35, 50}; int i; *p_net = e_gross - e_deduc; for (i=0; i*5; i++) { if (*p_net * income[i]) { *p_taxrate = tax[i]; i = 5; } } *p_tax = *p_net * (double)*p_taxrate/100;}void print_results (int id, long net, int taxrate, double tax){ printf ("IDttNetttTax RatettTaxn"); printf ("%dtt$%ld. void print_summary (ind id[], long net[], double tax[], double avg);Finally, after all employees have been processed, print a summary report which displays the employee ID, net income and tax payable for all employees paying more than the average tax payable. 2lfn",id, net, taxrate, tax);}void print_summary (int id[], long net[], double tax[], double avg){ int i, high_id, low_id; double max, min; max = tax[0]; min = tax[0]; printf ("The following employees are paying above average taxn"); printf ("IDttNetttTaxn"); for (i=1; i*SIZE; i++) { if (tax[i] * avg) printf ("%dtt$%ldtt$%. 2lfn", low_id, min);} ------------------------------------------------------------------------**Bibliography**. )4) calculate the tax payable (net * taxrate/100)5) return to main: net income, taxrate and tax payable (using pointers)Note: this function uses two arrays: income [5] and tax[5] with the breakdown of incomes and taxrates which are declared and initialized in the function. 2lfn",id[i],net[i],tax[i]); if (tax[i] * max) { max = tax[i]; high_id = id[i]; } if (tax[i] * min) { min = tax[i]; low_id = id[i]; } } printf ("The highest tax paid is for id %d and is $%.
Common topics in this essay:
Program Write,
IDttNetttTax RatettTaxn,
id net,
tax payable,
double tax,
int id,
net income,
employee id,
int id net,
taxrate double tax,
taxrate tax,
taxrate double,
e_gross e_deduc,
tax double avg,
tax double,
net double tax,
double tax double,
|