2017-10-20 39 views
0

更新版本。尋找猛禽地區降雨量的最高值和最低值

我已經想出了我以前的問題,但我仍然不確定如何做最後一部分。我不知道如何獲取括號內的數字,而不是獲取存儲在其中的值。數組由12個數字組成,例如我正在尋找可能是20的最高值,並且已經輸入到第4個點。我只能弄清楚如何讓它顯示20,但我想顯示4。它有用戶輸入,所以應顯示的數字可能會有所不同,我不確定如何完成此操作。
我只需要顯示最高和最低值的數組編號。我不知道我是否使用了錯誤的數組。

The main is the first section which is calling the other functions

The getInput function and assigns the entered values to one of 12 numbers in the array

The calculateTotal function which just adds all the values up.

The calculateAverage function which takes all the numbers entered and finds the average

The findHigh function which figures out which number entered is the highest. I have another function almost identical to this but finding the lowest. These are the two that need to show the arrays number and not the value that is saved inside of it.

displayResults function page which will display the values.

+0

我對你指的是哪一段迷茫。 – Matt

+0

對不起,當我發佈它看起來不同。第三張照片是它一直阻止我說的,並且說沒有找到最高值。 – alice83

回答

0

所以你有幾個問題,但容易修復。這隻會修復最高值的圖像3。

1)當設置highestValue你說的最高值等於[一月,amountOfRain。你需要說highestValue <- data[1,2]。這會指向amountOfRain

2.)您需要更改您的Call或您的變量highestValue的名稱,因爲它存在衝突。

給那些嘗試,讓我知道你得到什麼。