PDA

View Full Version : I don't understand what's wrong,


albear
Nov 9, 2007, 01:09 PM
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.

albear
Nov 9, 2007, 01:26 PM
Any suggestions?

albear
Nov 9, 2007, 01:43 PM
At all?

albear
Nov 9, 2007, 06:14 PM
Somebody?

albear
Nov 10, 2007, 09:56 AM
Anybody?

albear
Nov 10, 2007, 02:38 PM
Hello...

albear
Nov 11, 2007, 02:19 PM
Please...

qcumber
Nov 14, 2007, 09:22 PM
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

albear
Nov 20, 2007, 02:42 PM
Thank you, it was that