Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   Java (https://www.askmehelpdesk.com/forumdisplay.php?f=440)
-   -   I don't understand what's wrong, (https://www.askmehelpdesk.com/showthread.php?t=150260)

  • Nov 9, 2007, 01:09 PM
    albear
    i don't understand what's wrong,
    anyhelp would be great thank; OK then I have my code:

    class MySums // to calculate the average of three numbers,
    //one dealing with integers, the other with double
    {
    public static void main ( String [] args)

    {

    averageI(23, 45, 89);


    }
    public static int averageI (int num1, int num2, int num3)
    {

    int num4 = ((num1 + num2 + num3)/3);

    return num4;

    // calcualte the average of the three numbers
    // return the average

    }

    public static void averageI (double Num1, double Num2, double Num3)
    {

    double Num4 = ((Num1 + Num2 + Num3)/3);

    return Num4;

    System.out.println("integer average is " + averageI(23, 45, 89));
    }
    }

    its suppost to return the values Num4 and num4, but it says

    'cannot return a value from method whose result type is void, return Num4'
    ^(this is supposed to go under the N of Num4)

    I don't know what the problem means so I don't know how to correct it.
  • Nov 9, 2007, 01:26 PM
    albear
    Any suggestions?
  • Nov 9, 2007, 01:43 PM
    albear
    At all?
  • Nov 9, 2007, 06:14 PM
    albear
    Somebody?
  • Nov 10, 2007, 09:56 AM
    albear
    Anybody?
  • Nov 10, 2007, 02:38 PM
    albear
    Hello...
  • Nov 11, 2007, 02:19 PM
    albear
    Please...
  • Nov 14, 2007, 09:22 PM
    qcumber
    Your static method... instead of

    Public static void etc etc... you should change it to include a return type... for example,

    Public static int or public static double.. etc etc
  • Nov 20, 2007, 02:42 PM
    albear
    Thank you, it was that

  • All times are GMT -7. The time now is 10:21 AM.