10ArraysHard15 marks
A program is required to record and analyse the daily rainfall in millimetres for one year. Assume a year has 365 days.
The one-dimensional (1D) array Rainfall[] is used to store the daily rainfall measurements.
Write a program for the following requirements:
• Initialise the array Rainfall[] to zero.
• Input the rainfall measurement in millimetres for each day and store it in the array.
• Calculate the following statistics after all the inputs have been made for the year:
◦ the total rainfall for the year in centimetres (1 millimetres), rounded to two decimal places
◦ the mean average daily rainfall in millimetres, rounded to four decimal places
◦ the total number of days with no rainfall
◦ the longest number of consecutive days in which there was no rainfall.
• Output all the calculated statistics with clear and appropriate messaging.
• If the longest number of consecutive days in which there was no rainfall is 15 or more, output a message to indicate there was a drought (a long period when there is little or no rainfall).
You must use pseudocode or program code and add comments to explain how your code works.
All arrays, variables or constants used must be declared for this algorithm.
All inputs and outputs must contain suitable messages.
Answer
0 words