Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Java help

Options
  • 15-04-2016 8:04pm
    #1
    Closed Accounts Posts: 191 ✭✭


    Hi can someone please tell me why I have an error in my averageTemp method? Thanks


Comments

  • Registered Users Posts: 2,797 ✭✭✭mightyreds


    Hi can someone please tell me why I have an error in my averageTemp method? Thanks

    Do you have the method


  • Closed Accounts Posts: 191 ✭✭chocolate boy123


    Sorry i forgot to include my code...

    public static void main(String[] args) {
    // TODO Auto-generated method stub

    double temp [] = new double [6];

    for (int i=0; i<6; i++){
    double degree = Double.parseDouble(JOptionPane.showInputDialog("Enter the temperatures for the six months..."));
    double number = temp;
    }
    tempConvert(temp);
    double average = averageTemp(temp);


    }
    public static void tempConvert (double x[]){
    for (int i=0; i<x.length; i++){
    double F = 9 / 5 * i + 32;

    }
    public static double tempConvert (double y[]) {
    for (int count=0; count < y.length; count++){
    double sum = temp +=


    }
    }
    }
    }


  • Registered Users Posts: 1,263 ✭✭✭00sully


    Hi can someone please tell me why I have an error in my averageTemp method? Thanks

    Probably...

    "NoSuchMethodError"

    :pac:


  • Registered Users Posts: 2,797 ✭✭✭mightyreds


    As sully has pointed out you forgot the average temp code

    Plus the last line doesn't seem to be doing anything


  • Registered Users Posts: 1,463 ✭✭✭Anesthetize


    You have two methods called tempConvert but no averageTemp method.

    Also for readability use code tags when posting code.


  • Advertisement
  • Closed Accounts Posts: 191 ✭✭chocolate boy123


    I am aware The last line isn't finished I just want to get my methods working before I carry on. What do ye mean by my method is non existent, can ye please explain


  • Closed Accounts Posts: 191 ✭✭chocolate boy123


    I see what ye mean, I have changed my second method to average temp but still the same error.


  • Registered Users Posts: 2,797 ✭✭✭mightyreds


    Any an average method I'd usually go

    For int I=0; i<temp.length; i++
    Total+= temp(I)
    End for
    Average = total/temp.length-1
    Return average


    Could be wrong though I'm fairly drunk, that's all over the place cause I'm on my moblie too


  • Registered Users Posts: 1,463 ✭✭✭Anesthetize


    I am aware The last line isn't finished I just want to get my methods working before I carry on. What do ye mean by my method is non existent, can ye please explain
    You code above is calling a method called averageTemp, but you haven't implemented the code for this method.


  • Closed Accounts Posts: 191 ✭✭chocolate boy123


    I have the errors in these parts "double temperature = averageTemp(temp) and "public static double averageTemp(double y)" both errors are under "averageTemp


  • Advertisement
  • Registered Users Posts: 2,797 ✭✭✭mightyreds


    Will it not compile post the errors if you hover over the code


  • Closed Accounts Posts: 191 ✭✭chocolate boy123


    Multiple markers at this line
    -syntax error on token "(",; expected
    - illegal modifier for parameter averageTemp; only final is permitted
    - syntax error on token")",; expected


  • Closed Accounts Posts: 191 ✭✭chocolate boy123


    Here is a pic


  • Registered Users Posts: 306 ✭✭yes there


    Can someone delete this thread because this is just ridiculous and an embarrassment to have in the forum.


Advertisement