terça-feira, 14 de fevereiro de 2012

Correção exercicio de C# para calculo das médias.


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace estudantes
{
    class medias
    {
        static void Main(string[] args)
        {
            string[] nome = new string[10];
            double[,] notas = new double[10, 5];
            string[] colunas = new string[6]
            {"\nnome","nota-1","nota-2","nota-3","nota-4","média" };
            for (int i = 0; i < 10; i++)
            {
                Console.Write(colunas[0]);
                nome[i] = Console.ReadLine();
                for (int k = 0; k < 4; k++)
                {
                    Console.Write(colunas[k + 1]);
                    notas[i, k] = double.Parse(Console.ReadLine());
                    notas[i, 4] += notas[i, k] / 4;
                }
            }
            for (int i = 0; i < 10; i++)
            {
                Console.WriteLine(colunas[0]+nome[i]);
                for (int k = 0; k < 5; k++)
                {
                    Console.WriteLine(colunas[k + 1] + notas[i, k]);
                }
                if (notas[i, 4] >= 7) {
                    Console.WriteLine("Situação : Aprovado");
                }
                else if (notas[i, 4] >= 5 && notas[i, 4] < 7)
                {
                    Console.WriteLine("Situação : Prova final");
                }
                else {
                    Console.WriteLine("Situação : Reprovado");
                }              
            }
        }
    }
}

Nenhum comentário:

Postar um comentário

Obrigado por contribuir para melhorar este blog, deixe sua mensagem.
Forte Abraço