# Thread: missing return statement error

1. Member
Join Date
Oct 2012
Posts
1
Rep Power
0

## 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

2. Moderator
Join Date
Feb 2009
Location
New Zealand
Posts
4,712
Rep Power
14

## Re: missing return statement error

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.

3. ## Re: missing return statement error

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•