Final answer:
To monitor temperatures over a three-hour period, store the readings in an array, find the highest and lowest values, and then calculate the temperature difference. This routine provides min, max, and range of the temperature data.
Step-by-step explanation:
To write a routine that stores temperatures taken over a three-hour period in an array and outputs the highest and lowest temperatures and calculates the difference between them, consider the following approach:
- Initiate an array to store temperature readings.
- Collect temperature data at regular intervals over three hours and store each value in the array.
- Determine the highest and lowest temperature recorded.
- Calculate the difference between the highest and lowest temperatures.
For example:
- Create array: temperatures = []
- Record temperatures: temperatures.append(measured_temp)
- Find highest temp: max_temp = max(temperatures)
- Find lowest temp: min_temp = min(temperatures)
- Calculate difference: temp_difference = max_temp - min_temp
Output the highest, lowest temperatures, and the difference.