Help in programming module and variable increment

-2

I want to make a program that introduces a series of notes and once this in another part in a module that adds +1 for each suspended note and shows me the number of people who suspended, once all the notes are inserted.

He tells me only the last note and I do not know how to do it so that he takes into account the rest ...

static void Main (string [] args)         {             Notes();         }

    static void Notas()
    {
        int[] notas = new int[10];
        int incremento = 0;
        int nota = 0;

        while (incremento < 10)
        {
            Console.WriteLine("Ingresa un numero entre 0 i 10");
            nota = Convert.ToInt32(Console.ReadLine());
            if (nota < 0 || nota > 10)
                Console.WriteLine("El numero no es un valor correcto");
            else
                notas[incremento] = nota;
            incremento++;
        }
        Calculos(nota);
    }

    static void Calculos(int nota)
    {
        int suspe = 0;

        if (nota < 5)
        {
            suspe++;
            Console.WriteLine("Han suspendido {0}", suspe);
        }

        /*else if (nota <= 5)
        {
            if (nota == 5)
                Console.WriteLine("suficientes son {0}");
            else if (nota == 6 || nota == 7)
                Console.WriteLine(" bien son {0}");
            else if (nota == 8 || nota == 9)
                Console.WriteLine(" notables son {0}");
            else if (nota == 10)
                Console.WriteLine(" execl·lentes son {0}");
        }*/

    }
    
asked by josep canals 27.03.2018 в 19:27
source

1 answer

-1

Here I leave my solution, in the end what I did was create 4 variables within the calculation function that is the ke will contain the counters of the different notes, you can use an arrangement if you feel more comfortable. Declare static notes so you do not have to pass them to the Notes function, since from there you call Calculus and in the latter you need it to iterate and count. p>

static int[] notas;

static void Main(string[] args) {
    notas = new int[10];
    Notas(); 
}

static void Notas()
{        
    int incremento = 0;
    int nota = 0;

    while (incremento < 10)
    {
        Console.WriteLine("Ingresa un numero entre 0 y 10");
        nota = Convert.ToInt32(Console.ReadLine());
        if (nota < 0 || nota > 10)
            Console.WriteLine("El numero no es un valor correcto");
        else
            notas[incremento++] = nota;
    }
    Calculos(notas);
}

static void Calculos(int[] notas)
{
    int suspe = 0;
    int suficiente = 0;
    int bien = 0;
    int notables = 0;       
    foreach(int nota in notas){
        if (nota < 5)
        {
            suspe++;                
        }
        else 
        {
            switch(nota){
                case 5: 
                    suficiente++;
                    break;
                case 6: 
                case 7: 
                    bien++;
                    break;
                case 8:
                case 9:
                    notables++;
                    break;
                default:
                    excelente++;
                    break;
            }
        }
    }
    Console.WriteLine("suficientes son {0}", suficiente);
    Console.WriteLine("bien son {0}", bien);
    Console.WriteLine("notables son {0}", notables);
    Console.WriteLine("excelente son {0}", notas.length-suficiente-bien-notables-suspe);
}
    
answered by 27.03.2018 / 19:47
source