You're trying to compute the average before you've calculated the sums. Also, for each employee you need to reset the averageFeedBack variable so their feedback is calculated independent of everyone else's (I would just declare averageFeedback inside of the main loop to ensure it's reset each time through). For some reason, you've also got the array of results declared a 3-d array rather than a 2d array. FYI, in general people use doubles instead of floats because computers now have tons of memory, and doubles give more precision (and for some historical reasons, doubles have become the standard floating-point precision data type in many programming languages)
// 2d arrays look like this
float [][] result={
{3.5f, 2.2f, 2.8f},
{2.6f, 3.0f, 3.7f},
{4.0f, 3.4f, 1.0f},
{1.0f, 1.9f, 3.9f},
{4.0f, 4.0f, 4.0f}
};
// averaging code
for (int i = 0; i < 5; i++)
{
float averageFeedback = 0;
for (int j = 0; j < 3; j++)
{
averageFeedback += results[i][j];
}
a[i] = averageFeedback / 3;
}
A better approach to this problem would be to use an object that represents an employee, and have methods inside of that object that will automatically calculate the average feedback for that employee. Then, you'd only need to create an array of employees and use the employee's methods to generate all the information you need, cutting back greatly on code you need to type, debug, and maintain.
public class Employee
{
public int employeeNum;
public double [] feedback;
public Employee(int employeeNumber, double[] feedback)
{
this.employeeNum = employeeNumber;
this.feedback = feedback;
}
public double averageFeedback()
{
double sum = 0;
for (int i = 0; i < this.feedback.length; i++)
{
sum += feedback[i];
}
return sum / feedback.length;
}
public char feedbackGrade()
{
double ave = averageFeedback();
if (ave < 2)
{
return 'D';
}
else if (ave < 3)
{
return 'C';
}
else if (ave < 4)
{
return 'B';
}
else
{
return 'A';
}
}
}