PHP Challenge 2 - Working With Arrays and Array Functions
The highest recorded daily temperatures in degrees Celcius for the Sunshine Coast Airport weather station during January 2015 were:
32.3, 31.3, 28.2, 29.3, 29.7, 29.9, 28.7, 28.4, 30.5, 30.5, 31.7, 30.6, 29.4, 32.0, 36.2, 31.3, 32.8, 33.3, 32.9, 28.8, 30.8, 28.0, 25.9, 30.8, 32.4, 32.0, 31.3, 25.2, 29.1, 28.6, 30.6
Your challenge is to store the temperatures in an array and then to calculate the following:
the average daily temperature
the lowest 5 temperatures
the highest 5 temperatures
Present your results using appropriate presentation.
E.g.
The lowest 5 recorded temperatures at Sunshine Coast Airport in January 2015 were: 27.2, 28.3, 29.4, 29.5, 29.7
Extension
You may consider extending this task by converting temperatures from degrees Celcius to degrees Fahrenheit as required.
Also, consider how you will handle the decimal values when calculating the average temperature.
Would you like the solution to this challenge?
The full video solution together with downloadable code is available in the PHP for Beginners course.
This course is taught by Patrick Morrow, a national award-winning teacher, who is very active in the course and who provides full support.
To enrol in the course click here.