1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
|
//Declaring global constants
const int NUM_EMPLOYEES = 5;
//Function Prototypes
void LoadItemArrays(string empNum[], double salary2017[], double salary2018[], double salaryIncrease[], double totalIncreasePercentages, double averageOfIncreases);
void OutputSalaryDisplay (string empNum[], double salary2017[], double salary2018[], double salaryIncrease[], double averageOfIncreases);
int main()
{
string empNum[NUM_EMPLOYEES] = {};
double salary2017[NUM_EMPLOYEES],
salary2018[NUM_EMPLOYEES],
salaryIncrease[NUM_EMPLOYEES],
totalIncreasePercentages = 0,
averageOfIncreases = 0,
aboveAverage = 0,
belowAverage = 0,
equalToAverage = 0;
int k = 0;
//Function Calls
LoadItemArrays(empNum, salary2017, salary2018, salaryIncrease, totalIncreasePercentages, averageOfIncreases);
OutputSalaryDisplay(empNum, salary2017, salary2018, salaryIncrease, averageOfIncreases);
return 0;
}
void LoadItemArrays(string empNum[], double salary2017[], double salary2018[], double salaryIncrease[], double totalIncreasePercentages, double averageOfIncreases)
{
//declaring index variable
int k = 0;
for (k = 0; k < NUM_EMPLOYEES; k++)
{
cout << "\nEnter an employee number" << endl;
cin >> empNum[k];
cout << "\nEnter the employee salary in 2017" << endl;
cin >> salary2017[k];
cout << "\nEnter the employee salary in 2018" << endl;
cin >> salary2018[k];
salaryIncrease[k] = salary2018[k] - salary2017[k];
salaryIncrease[k] = salaryIncrease[k] / salary2017[k];
salaryIncrease[k] = salaryIncrease[k] * 100;
totalIncreasePercentages = totalIncreasePercentages + salaryIncrease[k];
system("cls");
}
//Calculating the average of the increases
averageOfIncreases = totalIncreasePercentages / NUM_EMPLOYEES;
}
void OutputSalaryDisplay(string empNum[], double salary2017[], double salary2018[], double salaryIncrease[], double averageOfIncreases)
{
//Declaring index variable
int k = 0;
//Outputting headings
cout << "Employee number" << left << setw(15) << "2017 Salary" << setw(18) << "2018 Salary" << right << setw(12) << "Increase %" << setw(12) << right << "Comment";
//Creating a for loop to output the employees data that is stored in the arrays.
for (k = 0; k < NUM_EMPLOYEES; k++)
{
cout << "\n\n" << left << setw(15) << empNum[k] << setw(18) << salary2017[k] << setw(12) << salary2018[k] << right << setw(12) << salaryIncrease[k] << setw(12) << right;
//If statement to determine whether the increase is above, below, or equal to average.
if (salaryIncrease[k] > averageOfIncreases)
{
cout << "Above Average" << endl;
}
else if (salaryIncrease[k] < averageOfIncreases)
{
cout << "Below Average" << endl;
}
else
{
cout << "Equal to Average" << endl;
}
}
cout << "The average of the increases is:" << averageOfIncreases;
Put the code you need help with here.
|