Results 1 to 3 of 3
Thread: missing return statement error
- 10-21-2012, 04:07 AM #1
Member
- Join Date
- Oct 2012
- Posts
- 1
- Rep Power
- 0
missing return statement error
public class SimpsonsParadox{
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 #2
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,545
- Rep Power
- 11
Re: missing return statement error
That's from the instructions - bold in the original and in the paragraph just preceding where the question starts.You should not use Scanner or have print statements in any of the required methods.
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 #3
Re: missing return statement error
Cross posted
Looking for help editing my java code? - Yahoo! Answers
Closed as 'Not a real question'
java - Trouble with writing a boolean expression - Stack Overflow
dbWhy do they call it rush hour when nothing moves? - Robin Williams
Similar Threads
-
Missing Return statement =[
By avirunes in forum New To JavaReplies: 6Last Post: 02-12-2011, 10:34 AM -
Missing return statement error.
By Fortu in forum New To JavaReplies: 2Last Post: 12-11-2010, 09:15 PM -
Missing Return Statement Error
By darkblue24 in forum New To JavaReplies: 13Last Post: 02-16-2010, 08:22 PM -
giving missing return statement error.due to withdraw method.
By qadeer37 in forum New To JavaReplies: 5Last Post: 01-16-2010, 11:14 PM -
Missing Return Statement error
By anilanar in forum New To JavaReplies: 2Last Post: 08-20-2009, 01:02 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks