Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I\'m having problems with this homework assisgnment for my C# Progamming class.

ID: 3915886 • Letter: I

Question

I'm having problems with this homework assisgnment for my C# Progamming class. I need help developing an application that will allow user to input monthly rainfall for one year, calculate and display the average rainfall for the year, and display the month name along with the rainfall amount and the total rainfalls for the year. I have most of the code worked through but I need help with the creating a method to return the rainfall for each month for the year in public static double[] GetRainfallAmounts()

Code:

namespace M3A2_CRainfallsApp
{
class Program
{
static void Main(string[] args)
{double[] rain = new double[12];

DisplayInformationAboutApp();
rain = GetRainfallAmounts();
ProduceReport(rain);
  
}

// Create a method to return the rainfall for each month for the year
public static double[] GetRainfallAmounts()
{
// Please implement your code to get the rainfalls from the user for the year.


}

public static string ReturnMonthName(int mon)
{
string monthName;
switch (mon)
{
case 0:
monthName = "January";
break;
case 1:
monthName = "February";
break;
case 2:
monthName = "March";
break;
case 3:
monthName = "April";
break;
case 4:
monthName = "May";
break;
case 5:
monthName = "June";
break;
case 6:
monthName = "July";
break;
case 7:
monthName = "August";
break;
case 8:
monthName = "September";
break;
case 9:
monthName = "October";
break;
case 10:
monthName = "November";
break;
case 11:
monthName = "December";
break;
default:
monthName = "Unknown";
break;
}
return monthName;
}

public static void ProduceReport(double[] rainArray)
{
double meanOfRainfall;

meanOfRainfall = rainArray.Average();

double totalRainfall = 0;


Console.Clear();
Console.WriteLine(" Rainfall App");
Console.WriteLine(" Average rainfall: {0:F1}", meanOfRainfall);
Console.WriteLine(" {0,-9} {1,9}", "Month", "Rainfall Amt.");
for (int i = 0; i < rainArray.Length; i++)
{
totalRainfall += rainArray[i];
Console.WriteLine("{0,-9} {1,9}",
ReturnMonthName(i), rainArray[i]);
}
Console.WriteLine(" Total rainfall for the year is: {0:f2} ", totalRainfall);

}
}
}

Explanation / Answer

please give thumbs up, thanks, for any query leave comment

CODE :

// Create a method to return the rainfall for each month for the year
public static double[] GetRainfallAmounts()
{
// Please implement your code to get the rainfalls from the user for the year.
double []rain= new double[12];
for(int i=0; i<12; i++)
{
Console.WriteLine("Enter Amount of rainfall for month "+ReturnMonthName(i));
rain[i]=double.Parse(Console.ReadLine());
}
return rain[];

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote