Data++
[Framework practical 2 of 7]


So, now we have some data, albeit fake data for the moment. Let's write a short section of code to do some processing on it. Let's find the maximum and minimum in the dataset.


 

In the Analyst class, after the code to fill and check the array, make yourself a double variable called "maximum" and set it to -1.0.


Below the code making your "maximum" variable and setting its initial value, implement the following algorithm:
(note: this is not real code - you'll need to work that out...)

// Loop through rows with index i.
// Loop through spaces on row with index j.
// if yourArrayName[i][j] > maximum, maximum = yourArrayName[i][j]
// End spaces loop.
// End rows loop.
// Print the final maximum to the screen.

A few questions with this: first, why do you think we make the maximum variable where we do? (think 'scope', and see last lecture) Secondly, why do we set it to -1.0?


 

Once you've got that working, under it, see if you can write more code to work out the minimum. What might you use as an initialisation value unstead of -1.0?


 

Once you've done that lot, you're done for this practical.