Task 1 Task 2 Task 3
Random Name

Task 1

A meteorologist uses a 7-element array to store the average rainfall (in cms) in Bangkok in for every day in the first week of November. The data is:

Write an algorithm in your programming language that will solve the following problems:

Declare a 7-element array and use a count-controlled loop to allow the meteorologist to INPUT 7 items of data - index 0 represents Monday's data.

The program will calculate and display:

  1. The total rainfall for the week.
  2. The average rainfall for the week.
  3. The index of the element that has the biggest rainfall.

Submit your solution in pseudocode. Remember to DECLARE any variables that your code uses.

Random Name

Task 2

A map-maker is storing heights in a mountain range. Data is stored in an array. A peak element is defined as an element whose value is greater than the previous value and greater than the next value. For example, the following represents an array of mountain heights.

As you can see, this example has an array of length 12. There are 4 peaks at indexes 1, 3, 8, 10.

Note that the height at index 0 can never be a peak because it does not have a preceding value. Also, the height at the last index can never be a peak.

Write pseudocode to count the number of peaks in the heights array. You can declare an array of any reasonable length eg 8 and populate it as you wish.

Note: prior to writing pseudocode, you may wish to actually code the solution using your programming language.

Another approach is to write the pseudocode algorithm and then use it to code your solution and see if it works as expected.

Random Name

Task 3

A Digital Audio program uses an array to store the length (in minutes) of each track on a CD.

A radio dj is able to search for a track with a specific time length and the program will display the index of that time . If there is more than one element with the time being searched for, any valid index is displayed. The program will run until the user enters 0.

Write pseudocode for the radio dj to solve this problem.

Research Extension: Design a Bubble Sort algorithm to sort the array into ascending order of track time length.