using System;
public class Program
{
public static void Main()
{
double[] numbers = new double[10];
//read data into the array
Console.WriteLine("Enter Ten decimal numbers of the Array");
for(int i=0; i<10; i++)
{
Console.Write("\nLocation[" + (i+0) + "]: ");
numbers[i] = double.Parse(Console.ReadLine());
}
//processing
double total, average, largest, smallest;
total = addnumbers(numbers);
average = averageFinder(numbers);
largest = largestFinder(numbers);
smallest = smallestFinder(numbers);
//DISPLAY
for(int x=0; x<10; x++)
{
Console.WriteLine("Numbers: " + numbers[x]);
}
Console.WriteLine("The Total of all the numbers is:" + total);
Console.WriteLine("The average of all the numbers is:" + average);
Console.WriteLine("The largest of all the numbers is:" + largest);
Console.WriteLine("The smallest of all the numbers is:" + smallest);
}//End of the main function
//Creating a function to add the numbers in an array
public static double addnumbers(double[] num)
{
//create a local variable called sum
double sum=0.0;
for(int x=0; x<10; x++)
{
sum = sum + num[x];
}
return sum;
}
//Creating a function called avaragefinder
public static double averageFinder(double[] num)
{
//create a local variable called avgg
double avg =0.0;
for (int x=0; x<10; x++)
{
avg = avg + num[x];
}
return avg/10.0;
}
//Creating a function called largestFinder
public static double largestFinder(double[] num)
{
//creating a local variable called largest
double largest = num[0];
for (int x=1; x<10; x++)
{
if (largest < num[x])
{
largest = num[x];
}
}
return largest;
}
//Creating a function called smallestFinder
public static double smallestFinder(double[] num)
{
//creating a local variable called smallest
double smallest = num[0];
for (int x=1; x<10; x++)
{
if (smallest > num[x])
{
smallest = num[x];
}
}
return smallest;
}
}