Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace RainPours
- {
- class Program
- {
- public static void MonthlyPours(int[] StationArray, Random randomGenVal)
- {
- for (int i=1;i<StationArray.Length;i++)
- {
- StationArray[i] = randomGenVal.Next(0,31);
- }
- }
- public static int MaxValMonth(int[] StationArray)
- {
- int MaxValArr = StationArray[0];
- int highestValDay = 0;
- for(int i=1;i<StationArray.Length;i++)
- {
- if(StationArray[i]>MaxValArr)
- {
- MaxValArr = StationArray[i];
- highestValDay = i;
- }
- }
- Console.WriteLine("The greatest value for this month is: {0} and the day it is on is {1}", MaxValArr, highestValDay);
- return MaxValArr;
- }
- public static void AvgMontly(int[] StationArray)
- {
- int Sum = StationArray[0];
- for (int i = 1; i < StationArray.Length; i++)
- {
- Sum += StationArray[i];
- }
- int Average = Sum / StationArray.Length;
- Console.WriteLine("The average is: {0}",Average);
- }
- public static void HigherThanAvgMonthly(int[] StationArray)
- {
- Console.Write("On these days the rain was higher than average: ");
- for (int i = 1; i < StationArray.Length; i++)
- {
- if (StationArray[i] > StationArray.Average())
- {
- Console.Write(" {0} ", i);
- }
- }
- Console.WriteLine();
- }
- public static void NoRainDays(int[] StationArray)
- {
- Console.Write("On these days there was no rain: ");
- for (int i=1;i<StationArray.Length;i++)
- {
- if(StationArray[i]==0)
- {
- Console.Write(" {0} ",i);
- }
- }
- Console.WriteLine();
- }
- public static void FindHighestValOfEach(int MaxValM1, int MaxValM2, int MaxValM3)
- {
- int top2Month = 0;
- int monthNo = 0;
- if(MaxValM1>MaxValM2)
- {
- top2Month = MaxValM1;
- monthNo = 1;
- }
- else
- {
- top2Month = MaxValM2;
- monthNo = 2;
- }
- if (MaxValM3>top2Month)
- {
- top2Month = MaxValM3;
- monthNo = 3;
- }
- Console.WriteLine("The greatest value amongst all is on month number: {0} and is {1}",monthNo,top2Month);
- }
- public static void TimesMaxMonthHappened(int[] StationArray,int MaxValMonth)
- {
- int repetitions = 0;
- for(int i=1;i<StationArray.Length;i++)
- {
- if(StationArray[i]==MaxValMonth)
- {
- repetitions++;
- }
- }
- Console.WriteLine("Times the max val of this month has repeated: {0}",repetitions);
- }
- static void Main(string[] args)
- {
- Random randomGenVal = new Random();
- int[] StationOne = new int[32];
- MonthlyPours(StationOne, randomGenVal);
- int[] StationTwo = new int[32];
- MonthlyPours(StationTwo, randomGenVal);
- int[] StationThree = new int[32];
- MonthlyPours(StationThree, randomGenVal);
- /*
- MaxValMonth(StationOne);
- MaxValMonth(StationTwo);
- MaxValMonth(StationThree);
- */
- Console.WriteLine();
- FindHighestValOfEach(MaxValMonth(StationOne), MaxValMonth(StationTwo), MaxValMonth(StationThree));
- Console.WriteLine();
- AvgMontly(StationOne);
- AvgMontly(StationTwo);
- AvgMontly(StationThree);
- Console.WriteLine();
- NoRainDays(StationOne);
- NoRainDays(StationTwo);
- NoRainDays(StationThree);
- Console.WriteLine();
- HigherThanAvgMonthly(StationOne);
- HigherThanAvgMonthly(StationTwo);
- HigherThanAvgMonthly(StationThree);
- Console.WriteLine();
- TimesMaxMonthHappened(StationOne,MaxValMonth(StationOne));
- TimesMaxMonthHappened(StationTwo, MaxValMonth(StationTwo));
- TimesMaxMonthHappened(StationThree, MaxValMonth(StationThree));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement