Drivers for a racing team complete test circuits.
They complete 3 test circuits every day from Monday to Friday.
The team monitors how many times a driver uses the in-car radio during each test to report a problem. This data is stored and analysed.
If we don't know how many rows a 2D array has, we can use .length eg nums.length
If we don't know how many columns a row has, we can also use .length eg nums[0].length
In this course, we will only process arrays where every row has the same number of columns.
So, we can see that the data set has 5 rows and each row has 3 columns.
Also, the data set has only 1 identifier, dataSet
So, dataSet[3][1] has a value of...?
Watch this Python video to see how to process a 2D array - could you code it in Java using your growing skills?!
A program processes an 2-dimensional array of values.
The array could have any number of rows, but each row will always have 4 elements.
Fill the blanks and check. Do you get it?!
rainfall = {
{2.3, 14.7, 4.1, 9.3},
{2.0, 12.0, 13.2, 7.9},
{3.3, 11.5, 9.2, 8.7}
}
max = 0
for(int i = 0; i<; i++){
for(int j = ; j<rainfall[i].length; j++){
if(rainfall[][] > max){
= rainfall[i][j]
}
}
}
System.out.println("The maximum amount of rainfall is "+max);
iterateauto-indent variablecompile sum machine code count-controlled loop integer pseudocodesyntax