16.4k views
5 votes
The snowfall totals for a given six (6) month period are as follows:

Nov - 5"
Dec - 11"
Jan - 30"
Feb - 22"
Mar - 14"
Apr - 2"
Given the above data, do the following:
A. Write pseudocode to compute the average monthly snowfall for the entire period.

1 Answer

3 votes

Final answer:

To compute the average monthly snowfall, initialize a total, add all monthly totals, divide by the number of months, and output the result. The average is found by adding the snowfall amounts for each month and then dividing by six.

Step-by-step explanation:

To compute the average monthly snowfall for the given six months period, you can follow these steps of pseudocode:


  1. Initialize a variable totalSnowfall to zero.

  2. Add the monthly snowfall totals to totalSnowfall: totalSnowfall = 5 + 11 + 30 + 22 + 14 + 2.

  3. Calculate the number of months (numMonths) which is 6.

  4. Divide totalSnowfall by numMonths to get the average: averageSnowfall = totalSnowfall / numMonths.

  5. Output the averageSnowfall.

Here is the pseudocode example:

BEGIN
SET totalSnowfall TO 5 + 11 + 30 + 22 + 14 + 2
SET numMonths TO 6
SET averageSnowfall TO totalSnowfall / numMonths
PRINT "The average monthly snowfall is: ", averageSnowfall, " inches."
END

User Anu Martin
by
8.3k points