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

Need help with this in C# IntegerFacts.cs Instructions 1 using static Systen.Con

ID: 3703101 • Letter: N

Question

Need help with this in C#

IntegerFacts.cs Instructions 1 using static Systen.Console; 2 class IntegerFacts 3 Create a program named IntegerFacts whose Main) method declares an array of 10 integers. static void Main() //Write your main here Call a method named FillArray to interactively fill the array with any number of values up to 10 or until a sentinel value (999) is entered. If an entry is not an integer, reprompt the user 7 public static int FillArray(int[] 10 array) public static void Statistics (intl] array, int els, out int high, out int low, out int sum, out double avg) 12 Call a second method named Statistics that accepts out parameters for the highest value in the array, lowest value in the array sum of the values in the arrav, and arithmetic average 13 15 16 In the Main() method, display all the statistics in the following format: Note: The inputs were 1, 11, and 999 The array has 2 values The highest value is 11 The lowest value is 1 The sum of the val The average is 6 ues is 12 Run Code Test Grade

Explanation / Answer

using System.IO;
using System;

class IntegerFacts
{
static void Main()
{
int[] array = new int[10];
int high=0, low = 0,sum=0;
double avg=0;
int els = FillArray(array);
Statistics(array, els,out high,out low,out sum,out avg);
Console.WriteLine("The array has "+els+" elements");

Console.WriteLine("The highest value is "+high);
Console.WriteLine("The lowest value is "+low);
Console.WriteLine("The sum of the values is "+sum);
Console.WriteLine("The averageis "+avg);
  
}
public static int FillArray(int[] array) {
int i;
for(i=0;i<10;i++) {
try {
Console.WriteLine("Enter an integer: ");
int n = Convert.ToInt32(Console.ReadLine());
if(n==999) {
break;
}
array[i]=n;
}catch(Exception e) {
i--;
}
  
}
return i;
}

public static void Statistics(int[] array, int els, out int high, out int low, out int sum, out double avg) {
high=array[0];
low=array[0];
sum=0;
for(int i=0;i<els;i++) {
sum+=array[i];
if(high<array[i])
high = array[i];
if(low>array[i])
low = array[i];
  
}
avg = sum/(double)els;
}
}

Output: