// Includes
#include "stdafx.h"
#include <iostream>
usingnamespace std;
// Main
int main()
{
//Variables
char names[10];
int salary[10];
int k,
n,
sum;
double average;
sum = 0;
average = 0;
k = 0;
n = 0;
// Employee Names
for (k = 0; k < 10; k++)
{
cout << "Enter employee name: " << endl;
cout << k + 1 << ". ";
cin.getline(names, 256);
}
cout << "\n";
//Salary
for (n = 0; n < 10; n++)
{
cout << "Enter the salary for employee: " << endl;
cout << n + 1 << ". $";
cin >> salary[n];
sum = sum + salary[n];
}
average = sum / 10;
cout << "\n";
for (k = 0; k < 10; k++)
{
cout << "The salary for " << names[k] << " is $" << salary[n] << endl;
}
cout << "\nThe average salary is $" << average << endl;
for (n = 0; n < 10; n++)
{
if (salary[n] < average)
{
k = k + 1;
}
elseif (salary[n] > average)
{
k = k + 1;
}
}
cout << "The number of salaries above average is " << k << endl;
cout << "The number of salaries below average is " << k << endl;
cout << "\nPress ENTER to exit...";
cin.clear();
cin.sync();
cin.get();
return 0;
}
at lines 44-47, it is supper to display all the employees name and salaries, but it is displaying as so, say the last name is kathy, it displays like this
the salary for k is $-860.....
the salary for a is $-860.....
the salary for t is $-860.....
so on and so forth.
it should display like this
the salary for kathy is $salary amount.
the salary suppose to be displayed is also a random number and its the same for every line.
I also need help with the below and above average loop, it displays the same for both.
Ok, I got that part fixed the names work, now i need the below average and above average, and also the salary for the names is being displayed as a random number like -86000000. or something like that, how do i fix this.