Question: Study the incomplete code below that calculates the total rainfall and average rainfall for Cape Town during May in mm . Select two ( 2

Study the incomplete code below that calculates the total rainfall and average rainfall for Cape Town during May in mm.
Select two (2) options below for the correct code (i) and (ii) that will perform the necessary calculations.
[Incorrect options will be negatively marked]
double[] rainfall ={20.5,15.2,10.8,5.3,5.0,5.5,5.7,10.1,15.9,25.4,30.2,22.6};
//-------(i)-----------
//total rainfall
//-------(ii)-----------
//average rainfall
//print
Console.WriteLine("Total rainfall for Cape Town in May (mm):"+ totalRainfall);
Console.WriteLine("Average rainfall for Cape Town in May (mm): "+ averageRainfall);
a.
//-------(i)-----------
//total rainfall
double totalRainfall =0;
for (int i =0; i < rainfall.Length; i++)
{
totalRainfall += rainfall[i];
}
b.
//-------(ii)------------
//average rainfall
double averageRainfall =0;
averageRainfall = totalRainfall / rainfall.Length;
c.
//-------(i)-----------
//total number of rainfall
double totalRainfall =0;
for (int i =0; i < rainfall.Length; i++)
{
totalRainfall = rainfall[i]++;
}
d.
//-------(ii)------------
//average rainfall
double averageRainfall = totalRainfall / rainfall.Length -1;
e.
//-------(i)-----------
//total number of rainfall
double totalRainfall =0;
for (int i =0; i < rainfall.Length-1; i++)
{
totalRainfall = rainfall[i]++;
}
f.
//-------(ii)------------
//average rainfall
double averageRainfall = rain

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Finance Questions!