Create a program named IntegerFacts whose Main() method declares an array of 10 integers.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.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 array, and arithmetic average.In the Main() method, display all the statistics in the following format: Note: The inputs were 1, 11, and 999The array has 2 valuesThe highest value is 11The lowest value is 1The sum of the values is 12The average is 6 using static System.Console;class IntegerFacts{ static void Main() { // Write your main here } public static int FillArray(int[] array) { } public static void Statistics(int[] array, int els, out int high, out int low, out int sum, out double avg) { } }

Respuesta :

Answer:

C# codee

using System;

class IntegerFacts

{

static void Main()

{

int[] x = new int[10];

int sum = 0;

int siz = 0, high = 0, low = 0, avg = 0;

siz = FillArray(x);

Statistics(x, ref high, ref low, ref sum, ref avg, siz);

Console.Write("The highest value is " + high);

Console.Write("\nThe lowest value is " + low);

Console.Write("\nThe sum of the values is " + sum);

Console.Write("\nThe average is " + avg);

}

static void Statistics (int [] b, ref int h, ref int l, ref int s, ref int a, int size)

{

if (size == 0)

h = l = s = a = 0;

else

{

int i =0;

l = 999;

h = 0;

s = 0;

for (; i < size;++i)

{

if(b[i] > h)

h = b[i];

if(b[i] < l)

l = b[i];

s += b[i];

}

a = s / size;

}

}

static int FillArray (int[] a)

{

int i = 0, count = 0;

int intTemp =0 ;

string temp;

for(i = 0 ; i < 10 ; i++)

{

Console.Write("Enter element number"+(i+1) +" : ");

temp = Console.ReadLine();

if (int.TryParse(temp, out intTemp)) {

if (intTemp != 999)

{

a[i] = intTemp;

count++;

}

else

break;

}

else

{

Console.Write("\n\nOops.. You entered a wrong number. Try again \n\n");

i--;

}

}

return count;

}

}

Explanation:

The output of the above program is given in the attached file.

Ver imagen abidhussain7972
ACCESS MORE