In C# 1.Write an application that allows the user to input monthly rainfall amou
ID: 3754748 • Letter: I
Question
In C#
1.Write an application that allows the user to input monthly rainfall amounts for one year storing the values in an array. Create a second array that holds the names of the month. Produce a report showing the month name along with the rainfall amount and its variance from the mean. Calculate and display the average rainfall for the year. Added to the specifications from the textbook, you should include as part of the final display a heading that includes your name along with a label that reads Summary of Data Produced By 'insert your name'.
Explanation / Answer
If you have any doubts, please give me comment...
using System;
namespace Rainfall{
class Program{
public static void Main(){
Console.WriteLine("Summary of Data Produced By ANUNAGA");
string[] months = new string[]{"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};
double[] rainfall = new double[12];
for(int i=0; i<12; i++){
Console.Write("Enter rainfall amount for month "+months[i]+": ");
double.TryParse(Console.ReadLine(), out rainfall[i]);
}
Console.WriteLine(" Month Rainfall");
double avgRainfall = 0.0;
for(int i=0; i<12; i++){
Console.WriteLine(months[i]+" "+rainfall[i]);
avgRainfall += rainfall[i];
}
avgRainfall /= 12.0;
Console.WriteLine(" Average Rainfall for the year is: "+avgRainfall);
}
}
}