GoConqr has a new look! Let us know what you think.

Module 8 of 9 · Text

Arrays - 2

Anthony Anthony

namespace Proyecto
{
    internal class Program
    {
        static void Main(string[] args)
        {
            //TODO: Cuando se llaman a metodos se crea una nueva variable del mismo tipo y la pasa al metodo
            double[] arrayMedia = new double[5];
            RellenarArray(arrayMedia);

            Console.WriteLine("La media de las notas es {0}", CalcularMedia(arrayMedia));
        }

        public static void RellenarArray(double[] array)
        {

            int i = 0;

            do
            {
                Console.WriteLine("Introduce la nota {0}", i + 1);
                double numeroMedia = double.Parse(Console.ReadLine());

                array[i] = numeroMedia;
                i++;

            }
            while (i < array.Length);

        }

        public static double CalcularMedia(double[] array)
        {
            double mediaTotal = 0;

            for (int i = 0; i < array.Length; i++)
            {
                mediaTotal += array[i];
            }
            return mediaTotal /= array.Length;
        }
    }
    }

Instructions

You must submit an attempt for this quiz to progress. You can submit it after the last question.

Go to the chosen module

Feedback

What is it about?

What do you think of the new look?

How do you like it?