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

  • 15-04-2016 08:04PM
    #1
    Closed Accounts Posts: 191
    ✭✭


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


Welcome!

It looks like you're new here. Sign in or register to get started.

Comments

  • Registered Users, Registered Users 2 Posts: 2,872 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, Registered Users 2 Posts: 1,267 00sully
    ✭✭✭


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

    Probably...

    "NoSuchMethodError"

    :pac:


  • Registered Users, Registered Users 2 Posts: 2,872 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, Registered Users 2 Posts: 1,467 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, Registered Users 2 Posts: 2,872 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, Registered Users 2 Posts: 1,467 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, Registered Users 2 Posts: 2,872 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, Registered Users 2 Posts: 306 yes there
    ✭✭


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


Welcome!

It looks like you're new here. Sign in or register to get started.
Advertisement