Question: ON CENGAGE MINDTAP Create a program named FlexibleArrayMethod that declares at least three integer arrays of different sizes. In turn, pass each array to a

ON CENGAGE MINDTAP Create a program named FlexibleArrayMethod that declares at least three integer arrays of different sizes. In turn, pass each array to a method named DisplayAndSum that displays all the integers in each array and their sum. C# language

This is my code and it is saying it is wrong. \

using System;

public class FlexibleArrayMethod

{

public static void Main()

{

int[] arr1 = {3, 9, 1};

int[] arr2 = {98, 89, 81, 85};

int[] arr3 = {-3, -8, 9, 2, 6, -7};

DisplayAndSum(arr1);

DisplayAndSum(arr2);

DisplayAndSum(arr3);

}

public static void DisplayAndSum(int[] arr)

{

double total = 0;

Console.Write("Array is: {0}");

for(int i = 0; i < arr.Length; i++) {

total += arr[i];

Console.Write(arr[i] + " ");

}

double average = total / arr.Length;

Console.WriteLine("Average is {0}" + average);

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!