#K78757. Average Temperature Calculation
Average Temperature Calculation
Average Temperature Calculation
You are given a list of temperature readings. Your task is to compute the average temperature. The average should be rounded to 2 decimal places. In the case of an empty list, the answer is defined to be 0.0.
Mathematically, if you are given temperatures \(T = [t_1, t_2, \dots, t_n]\) with \(n > 0\), you should compute the average as:
\(\text{average} = \frac{t_1 + t_2 + \cdots + t_n}{n}\)
The result must be rounded to 2 decimal places. If there are no temperature readings (i.e. the list is empty), output 0.0.
inputFormat
The first line of input contains a single integer \(n\) indicating the number of temperature readings. If \(n > 0\), the second line contains \(n\) space-separated real numbers representing the temperature readings. If \(n = 0\), there are no temperature readings.
outputFormat
Output a single line containing the average temperature rounded to 2 decimal places if \(n > 0\), or 0.0 if the list is empty.
## sample5
23.5 18.7 26.8 22.1 19.0
22.02