Back to Challenge Set 14

Code Challenge: Temperature Log

Difficulty  

divider

The Brief

What they asked for
A week of afternoon readings from the greenhouse sensor, in
degrees. Give me the lowest, the highest, and the average,
and tell me which days went above 80 so I know when to check
the vents.

Write your requirements list before you write any code. Input, calculate, output, and anything you had to decide for yourself.


Notes

  • Start with the seven readings in an array: 68, 74, 81, 77, 85, 72, 79. Day 1 is the first.
  • The lowest and the highest are two running comparisons, Activity 1.20's pattern. Start both from the first reading, not from a number you picked — that is the trap in this one, and a week of warm days will show you why.
  • Report the average to one decimal place.
  • “Which days” needs the position as well as the reading, so that loop needs the index.

Sample Output

Sample Output
Lowest: 68 Highest: 85 Average: 76.6
Above 80:
Day 3: 81
Day 5: 85

Verified in a real run.


Submit

Your requirements list and your program file, named cc-temperature-log.

Commence Challenge