I have just starting and i am new to programming. I am doing an exercise where i have to ask the user for the rainfall for each month over a period of years of his or hers own choosing.The program needs to show the total rainfall for the year and the average rainfall per month. I am stuck on 2 things,
1st is how do i get the loop to recognize the amount of the years the user has entered (eg): if he or she enters 2 years that after year one year the 2nd starts.At the minute it is only running for 1 year.
2nd problem i have is,at the end of the year i can't seem to get the totals the user has entered for each month to display.How can i get these from the array.I have attached my coding below. Any help i could get on this is very much appreciated,thanks
namespace RainFall
{
class Program
{
static void Main(string[] args)
{
int Numyears = 0;
//int Month = 12;
double Rainfall = 0.0;
double avrRainfall = 0.0;
string[] Month = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
Console.WriteLine("please enter number of years");
Numyears = int.Parse(Console.ReadLine());
while(Numyears <= 0)
{
Console.WriteLine("Minimum number of years is 1 Please re-enter");
Numyears = int.Parse(Console.ReadLine());
}
for(int i = 0; i < Month.Length; i ++)
{
Console.WriteLine(" Enter inches of rainfall for {0}", Month[i]);
Console.ReadLine();
}
for (int i = 0;i < Month.Length; i++)
{
Console.WriteLine(" {1} Total;", i + 1, Month[i]);
}
}
}
}