*You will write a program for a small business (company). The program computes and prints the net*

pay for different employees at the end of each month. It also computes and prints a summary of the

payroll for that month.

pay for different employees at the end of each month. It also computes and prints a summary of the

payroll for that month.

It is menu driven and the first menu option should Compute and Print the Pay for an Employee. This is done using a number of functions, as seen in my code here:

/******************************************************************** * * I declare that the following program was written by me and that I * have NOT copied any part of this code from any other source. * * Name: George Strawbridge * * Email: [email protected] * * Date: 5/11/2018 * * *********************************************************************/ /* This is a template with the functions you must implement for this assignment. * * Note that you are free to implement any additional function you consider appropriate. */ //variables relating to the tax of an individual employee #include <stdio.h> #include <stdlib.h> float annualSalary, taxableIncome, taxableIncome, annualIncomeTax, annualNatInsurance, annualNatInsurance1, annualNatInsurance2, monthlyNatInsurance, monthlyNetPay, monthlyPreTax, monthlyIncomeTax, tempvar; int age, personalAllowance = 11850; //Returns the personal allowance of a person with the given annual salary float compute_personal_allowance(float annualSalary) { if (annualSalary <= 100000) { personalAllowance = 11850; } else(annualSalary > 100000); { personalAllowance = 11850 - 1 * ((annualSalary - 100000) / 2); } return personalAllowance; } //Returns the taxable income of a person with the given annual salary and personal allowance float compute_taxable_income(float annualSalary, float personalAllowance) { if (annualSalary < 11850); { taxableIncome = 0; } if (annualSalary <= 100000); { taxableIncome = annualSalary - personalAllowance; } if (annualSalary > 100000); { taxableIncome = annualSalary - (11850 - 1 * ((annualSalary - 100000) / 2)); } return taxableIncome; } //Returns the annual income tax of a person with the given taxable income float compute_annual_income_tax(float taxableIncome) { if (annualSalary <= 34500); { annualIncomeTax = ((taxableIncome * 20) / 100); } if (34501 <= annualSalary && 150000 <= annualSalary); { annualIncomeTax = ((taxableIncome * 40) / 100); } if (annualSalary > 150000); { annualIncomeTax = ((taxableIncome * 20)/100) + (40/100) * (taxableIncome - 34500); } return annualIncomeTax; } //Returns the annual national insurance for a person with the given annual salary and age. float compute_annual_national_insurance(float annualSalary, int age) { if (age > 65) { annualNatInsurance = 0; } else(age < 65); { if (annualSalary < 8424) { annualNatInsurance = 0; } else if (8424 >= annualSalary && 46350 <= annualSalary); { annualNatInsurance = ((annualSalary * 12) / 100); } if (annualSalary > 46350) { if (annualSalary < 46350) { annualNatInsurance1 = ((annualSalary * 12) / 100); } else(annualSalary > 46350); { annualNatInsurance2 = ((annualSalary * 2) / 100); } annualNatInsurance = annualNatInsurance1 + annualNatInsurance2; } return annualNatInsurance; } } //Computes the monthly net pay of a person with the given annual salary, annual income tax, and annual national insurance float compute_monthly_net_pay(float annualSalary, float annualIncomeTax, float annualNatInsurance) { monthlyPreTax = annualSalary / 12; monthlyIncomeTax = annualIncomeTax / 12; monthlyNatInsurance = annualNatInsurance / 12; monthlyNetPay = (monthlyPreTax) - (monthlyIncomeTax) - (monthlyNatInsurance); return monthlyNetPay; } /*Enters a person with a given annual salary and age into the system. This#include <stdio.h> #include <stdlib.h> function uses the functions above to compute and update the cumulative statistics, namely: A. The total amount of money paid out by the company to all employees. B. The average net monthly salary. C. The maximum income tax paid by any employee. D. The minimum income tax paid by any employee. hint: store the values into global variables, so that the functions below can return them. */ void add_person(int age, float annualSalary){ printf("Age: %d\n", age); printf("Salary: %f\n", annualSalary); } //Returns the total money paid by the company to the employees entered //into the system through add_person() float get_total_money_paid() { } //Returns the average net salary of all the employees entered into the //system through add_person() float get_average_net_salary() { } //Returns the maximum income tax paid by any of the employees entered into the //system through add_person() float get_maximum_income_tax() { } //Returns the minumum income tax paid by any of the employees entered into the //system through add_person() float get_minimum_income_tax() { } int main() { //Declare our variables //Control variable for choosing menu option int menuChoice = 0; printf("Hello. Welcome to the program.\n"); printf("Press any key to continue...\n"); getchar(); system("clear"); while (menuChoice != 3) { //prints the menu printf("\nMain Menu\n"); printf("-----------\n"); printf("1. Compute and Print the Pay for an Employee\n"); //Menu for user to select what they want to do printf("2. Show Sums and Statistics\n"); printf("3. Quit the program\n"); printf("-----------\n\n"); printf("Enter choice (1, 2, or 3)\n"); scanf("%d", & menuChoice); //Scans and stores users input if (menuChoice == 1) //if statement for what to do depending on what option is selected by the user { printf("Please enter the age of the employee in years:\n"); scanf("%d", &age); printf("Please enter the annual salary of the employee:\n"); scanf("%f", &annualSalary); add_person(age, annualSalary); compute_personal_allowance(annualSalary); compute_taxable_income(annualSalary, personalAllowance); compute_annual_income_tax(taxableIncome); compute_annual_national_insurance(annualSalary, age); compute_monthly_net_pay(annualSalary, annualIncomeTax, annualNatInsurance); printf("Employee Age: %d\n", age); printf("Annual Salary: %f\n", annualSalary); printf("Taxable Income: %f\n", taxableIncome); printf("Monthly Income Tax: %f\n", monthlyIncomeTax); printf("Monthly National Insurance: %f\n", monthlyNatInsurance); printf("Net Monthly Pay: %f\n", monthlyNetPay); } return 0; } }

So for example, I enter Age: 20 and Salary: 8000. This is what I get:

Age: 20 Salary: 8000.000000 Employee Age: 20 Annual Salary: 8000.000000 Taxable Income: -49850.000000 Monthly Income Tax: -830.833313 Monthly National Insurance: 80.000000 Net Monthly Pay: 1417.500000

I'm unsure as to why I'm getting negatives for both Taxable Income and Monthly Income Tax. I can't spot the mistake in my logic. Everything else seems okay though so that's at least something.

Any pointers guys? Would greatly appreciated.

PS. For this assignment, this is a requirement:

Compute the following monthly sums and statistics:

A.

The total amount of money paid out by the company to all employees.

B.

The average net monthly salary.

C.

The maximum income tax paid by any employee.

D.

The minimum income tax paid by any employee.

A.

The total amount of money paid out by the company to all employees.

B.

The average net monthly salary.

C.

The maximum income tax paid by any employee.

D.

The minimum income tax paid by any employee.

I am not allowed to use arrays, structs, or pointers, so what's the best way to go about storing data for multiple people? I'm guessing a for loop? Would appreciate a kick in the right direction. Thanks.