-1

The code is supposed to double the mean and provide a score, i.e. 4.2231 is mean, but this code prints 4.0.

public Double mean(){
    return Double.valueOf((sum() / sequence.length));
}

For this line, for example, 1 is the sequence.length.

It should print out "is wobbly" when sequence.length is less then 1 or when the list of numbers have no particular order, but this code makes it print out increasing. How do I make it so when sequence.length = 1, print wobbly. Or how should I improve my decreasing code to avoid that breach in the future

public  boolean isIncreasing() {
    int temp;
    boolean flag = true;
    for (int index = 0; index < sequence.length - 1; index++) {
        temp = sequence[index];
        if (temp > sequence[index + 1])
        {
            flag = false;
            break;
        }
    }
    return flag;
}
user207421
  • 305,947
  • 44
  • 307
  • 483

1 Answers1

-1

In java, in order to make a division return a double value, you need that divisor or dividend is a double, so for your case this should work:

return (Double.valueOf(sum()) / sequence.length);
Billy
  • 96
  • 5