Unable 2 compile

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • grabonlee
    New Member
    • Jul 2007
    • 8

    Unable 2 compile

    Please I'm trying to compile the program. I'm being asked for a return type and variable. Please could u fix it. The program is meant 2 calculate the mean of up to 10000 randomly generated numbers. Thanks


    [CODE=java] class Test1
    {

    static float mu1,mean1;

    public static void setMean(float mu1)
    {
    mean1=mu1;
    }
    public static float[] generateRandom( )
    {
    Random generator = new Random();
    float total=0.0f;

    int count = 10000;

    for(int i = 0; i<count; i++){
    total += (float)generato r.nextGaussian( );

    float am[] = new float[2];
    am[0] = total;
    }
    }
    }


    public class Test

    {
    public static void main(String[] args)

    {

    Test1 bgg = new Test1();

    bgg.setMean(1.0 f);

    float[] x = bgg.generateRan dom();

    System.out.prin tln("["+ x[0]+"]");

    }
    }[/CODE]
    Last edited by prometheuzz; Jul 22 '07, 06:51 PM. Reason: Added code tags
  • prometheuzz
    Recognized Expert New Member
    • Apr 2007
    • 197

    #2
    Originally posted by grabonlee
    Please I'm trying to compile the program. I'm being asked for a return type and variable. Please could u fix it. The program is meant 2 calculate the mean of up to 10000 randomly generated numbers. Thanks
    No, I'm not going to fix it. But if you copy-n-paste the compiler errors, I'll (try to) help you with them so that you can fix it yourself. Do we have a deal?

    Comment

    • grabonlee
      New Member
      • Jul 2007
      • 8

      #3
      Originally posted by prometheuzz
      No, I'm not going to fix it. But if you copy-n-paste the compiler errors, I'll (try to) help you with them so that you can fix it yourself. Do we have a deal?
      Here it is:

      C:\Documents and Settings\Grabon lee\Desktop\Rew ork1>javac Test.java
      .\Test1.java:27 : missing return statement
      }
      ^
      1 error

      C:\Documents and Settings\Grabon lee\Desktop\Rew ork1>

      Comment

      • mailanusha
        New Member
        • Jun 2007
        • 6

        #4
        In your code
        public static float[] generateRandom( )
        {
        //enclosing block
        }
        The return statement must be float[] according to " public static float[] generateRandom( ) " but you have not given any return statement within the enclosing block.

        Comment

        Working...