# missing return statement error

• 10-21-2012, 04:07 AM
Joshkesner
missing return statement error

public static boolean isSimpsonExample(int p1y1S, int p1y1T, int p2y1S, int p2y1T, int p1y2S, int p1y2T, int p2y2S, int p2y2T){

p1y1S = 12;

p1y1T = 48;

p2y1S = 104;

p2y1T = 411;

p1y2S = 183;

p1y2T = 582;

p2y2S = 45;

p2y2T = 140;

{
if ((((p1y1S/p1y1T)+(p1y2S/p1y2T)/2) > (((p2y1S/p2y1T)+(p2y2S/p2y2T))/2) && ((p2y1T + p2y1T) > (p1y1T +p1y2T))) || (((p1y1S/p1y1T)+(p1y2S/p1y2T)/2) < (((p2y1S/p2y1T)+(p2y2S/p2y2T))/2) && ((p2y1T + p2y1T) < (p1y1T +p1y2T)))) {
System.out.println("true");
}else{
System.out.println("false");

}
}
}
}

that's my code, although very sloppy, i figure it should work but i keep getting an error: missing return statement and cannot figure out how to fix it. Any advice would be great

thanks
• 10-21-2012, 04:28 AM
pbrockway2
Re: missing return statement error
Quote:

You should not use Scanner or have print statements in any of the required methods.
That's from the instructions - bold in the original and in the paragraph just preceding where the question starts.

At least in the version you hand in those print() statements shouldn't be there. So what should be in the body of the if statement with them gone? The answer is a return statement. You method is declared to return a boolean, and so there should be a return statement in there somewhere.

---

Read what the assignment says about where the test values should go. (not in the code of this method). And I think you have an extra set of braces in there.
• 10-21-2012, 06:38 AM
DarrylBurke
Re: missing return statement error