static String Q3(int a, int b, int c, double lowerBound, double targetValue, double upperBound) {
If I run this
System.out.println(Q3(74, 9, 48, 18.4, 38.4, 112.1));
System.out.println(Q3(22, 8, 16, -9.0, 38.3, 124.5));
System.out.println(Q3(31, 32, 35, 20.7, 35.1, 88.2));
System.out.print(Q3(22, 8, 16, -9.0, 38.3, 124.5));
I have to get almost, just right, just right, and almost . I keep getting
almost
null
null
null
What I have tried:
static String Q3(int a, int b, int c, double lowerBound, double targetValue, double upperBound) {
double avg = (a+b+c)/3;
String result = null;
if(avg < lowerBound){
result = "too low";
}
else if(avg > upperBound){
result = "too high";
}
else if(targetValue - 2.5 <= avg && avg <= targetValue + 2.5){
result = "just right";
}
else if(lowerBound < avg && avg < upperBound && targetValue - 2.5 < avg && targetValue + 2.5 < avg){
result = "almost";
}
else{
return result;
}
return result;
}