A researcher samples the temperature of a container over time. This is recorded as a series
of data points, each data point a time (in seconds) and a temperature (in Celsius). The goal
is to calculate statistics associated with the data: the minimum and maximum temperatures,
the average temperature and the halfway temperature.
Instructions
Write a program called temperature.c that:
1. Prompts for the number of data points. (Error checking: there must be at most 40 data
points.)
2. Reads in the data into two arrays. (Error checking: the temperatures must be nonnegative
and the data points in chronological order starting at time 0.)
3. Calculates the minimum and maximum temperature.
4. Calculates the average temperature. For this we assume that the data points are joined
by straight lines: the average is thus the area under the curve divided by the total time.
5. Calculates the temperature at the halfway point. Again we assume that the data points
are joined by straight lines.
Sample Run
How many data points? 4
Enter time and temp (0): 0 0
Enter time and temp (1): 10 20
Enter time and temp (2): 15 -5
-5.000000 invalid temp
Enter time and temp (2): 16 16
Enter time and temp (3): 12 23.5
12.000000 invalid time
Enter time and temp (3): 22 24.5
Minimum temperature was 0.00
Average temperature was 14.98
Middle temperature was 19.33
Requirements
1. Submit your source code using: handin.111.302 3 temperature.c
2. You are to work independently, but can ask questions from the lecturer, lab instructors,
tutor and helpdesk. Late programs will be penalized.