public class main {
public static void main(String[] args) {
aboveAverageTester();
}
public static int aboveAverage(int a, int b, int c, int d, int e, int f) {
//This method computes the average of the parameters
//and then returns how many of the parameters are above the average.
int avg = (a + b + c + d + e + f) / 6;
int above = 0;
if (a > avg) {
return a;
}else if (b > avg) {
return b;
}else if (c > avg) {
return c;
}else if (d > avg) {
return d;
}else if (e > avg) {
return e;
}else if (f > avg) {
return f;
}else{
return a + b + c + e + f;
}
}
public static int aboveAverageTester() {
int aboveAverage = aboveAverage(10, 10, 10, 10, 45, 50);
System.out.println(aboveAverage);
return aboveAverage;
}
}
I know the aboveAverage method logic may be completely off, but I'm getting a problem when I'm trying to return how many of the parameters are above the average.
From my code, I believe that when you keep returning like a, b ,c.. etc after each if-- it's just 1 instance and not adding to the list of others that my be larger than the average.
I'm trying to preform this without printing anything in this method, only logic.
I know I kind of messed up, also, at the bottom of the aboveAvg method by adding all the a,b,c,d,e,f and not just creating a list from them.
Can anyone give me an idea of how to approach this?