Weather Homework Practice
| # | Answer |
|---|---|
| 1 | 1. Add all temperatures together. 2. Count the number of days. 3. Divide the sum by the count. 4. Return the result as the average. |
| 2 | START INPUT weather IF weather = 'sunny' THEN print 'Wear sunglasses and light clothing.' ELSE IF weather = 'rainy' THEN print 'Bring an umbrella and wear a raincoat.' ELSE IF weather = 'snowy' THEN print 'Wear a heavy coat, gloves, and boots.' ELSE print 'No recommendation available.' END |
| 3 | Example: { city: 'Chicago', temperature: 64, humidity: 58, windSpeed: 12 } - city: the name of the location - temperature: the current air temperature - humidity: the percentage of moisture in the air - windSpeed: how fast the wind is blowing |
| 4 | FUNCTION weatherAlert(windSpeed, rainfall) IF windSpeed > 40 OR rainfall > 2 THEN RETURN 'Storm Warning' ELSE RETURN 'Normal Conditions' END IF END FUNCTION |
| 5 | 1. Store the 7 daily temperatures in an array/list. 2. Initialize variables for total and hottestDay. 3. Loop through the temperatures. 4. Add each temperature to the total. 5. Compare each temperature to the current highest value. 6. If a temperature is higher, update the hottest temperature and record its day index. 7. After the loop, compute the average by dividing total by 7. 8. Display the average temperature and the hottest day with its temperature. |