Results 1 to 3 of 3
  1. #1
    Joshkesner is offline Member
    Join Date
    Oct 2012
    Rep Power

    Default 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)))) {


    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


  2. #2
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    New Zealand
    Rep Power

    Default 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. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Madgaon, Goa, India
    Rep Power

    Default Re: missing return statement error

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Missing Return statement =[
    By avirunes in forum New To Java
    Replies: 6
    Last Post: 02-12-2011, 10:34 AM
  2. Missing return statement error.
    By Fortu in forum New To Java
    Replies: 2
    Last Post: 12-11-2010, 09:15 PM
  3. Missing Return Statement Error
    By darkblue24 in forum New To Java
    Replies: 13
    Last Post: 02-16-2010, 08:22 PM
  4. Replies: 5
    Last Post: 01-16-2010, 11:14 PM
  5. Missing Return Statement error
    By anilanar in forum New To Java
    Replies: 2
    Last Post: 08-20-2009, 01:02 AM

Tags for this Thread

Posting Permissions

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