Esempio n. 1
0
        static void Main(string[] args)
        {
            Aluno[] alunos       = new Aluno[5];
            var     indiceAluno  = 0;
            string  opcaoUsuario = obeterOpcaoUsuario();

            while (opcaoUsuario.ToUpper() != "X")
            {
                switch (opcaoUsuario)
                {
                case "1":
                    //TODO: Adicionar alunos
                    Console.WriteLine("Informar o nome do aluno: ");
                    Aluno aluno = new Aluno();
                    aluno.Nome = Console.ReadLine();

                    Console.WriteLine("Informe a nota do aluno: ");
                    if (decimal.TryParse(Console.ReadLine(), out decimal nota))
                    {
                        aluno.Nota = nota;
                    }
                    else
                    {
                        throw new ArgumentException("O valor da nota deve ser décimal!!");
                    }

                    alunos[indiceAluno] = aluno;
                    indiceAluno++;

                    break;

                case "2":
                    //TODO: Listar alunos
                    foreach (var a in alunos)
                    {
                        if (!string.IsNullOrEmpty(a.Nome))
                        {
                            Console.WriteLine($"Nome : {a.Nome} -- Nota : {a.Nota}");
                        }
                    }
                    break;

                case "3":
                    //TODO: Calcular Média Geral

                    decimal notaTotal = 0;
                    var     nrAlunos  = 0;

                    for (int i = 0; i < alunos.Length; i++)
                    {
                        if (!string.IsNullOrEmpty(alunos[i].Nome))
                        {
                            notaTotal = notaTotal + alunos[i].Nota;
                            nrAlunos++;
                        }
                    }


                    var      media = notaTotal / nrAlunos;
                    Conceito conceitoGeral;

                    if (media < 2)
                    {
                        conceitoGeral = Conceito.E;
                    }
                    else if (media < 4)
                    {
                        conceitoGeral = Conceito.D;
                    }
                    else if (media < 6)
                    {
                        conceitoGeral = Conceito.C;
                    }
                    else if (media < 8)
                    {
                        conceitoGeral = Conceito.B;
                    }
                    else
                    {
                        conceitoGeral = Conceito.A;
                    }

                    Console.WriteLine($"A média é : {media} -- Conceito : {conceitoGeral}");

                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
                opcaoUsuario = obeterOpcaoUsuario();
            }
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            Aluno[] alunos       = new Aluno[5];
            var     indiceAluno  = 0;
            string  opcaoUsuario = ObterOpcaoUsuario();

            while (opcaoUsuario.ToUpper() != "X")
            {
                switch (opcaoUsuario)
                {
                case "1":
                    Console.WriteLine("Digite o Nome do Aluno:");
                    var aluno = new Aluno();
                    aluno.Nome = Console.ReadLine();

                    Console.WriteLine("Digite a Nota do Aluno:");

                    if (double.TryParse(Console.ReadLine(), out double nota))
                    {
                        aluno.Nota = nota;
                    }
                    else
                    {
                        throw new ArgumentException("Valor da Nota deve conter casas Decimais!!!");
                    }

                    alunos[indiceAluno] = aluno;
                    indiceAluno++;

                    break;

                case "2":
                    foreach (var a in alunos)
                    {
                        if (!string.IsNullOrEmpty(a.Nome))
                        {
                            Console.WriteLine($"ALUNO(A): {a.Nome} - NOTA: {a.Nota}");
                        }
                    }
                    break;

                case "3":
                    double notaTotal = 0;
                    var    nrAlunos  = 0;

                    for (int i = 0; i < alunos.Length; i++)
                    {
                        if (!string.IsNullOrEmpty(alunos[i].Nome))
                        {
                            notaTotal += alunos[i].Nota;
                            nrAlunos++;
                        }
                    }

                    var mediaGeral = (notaTotal / nrAlunos);
                    Console.WriteLine("A Média Geral é: " + mediaGeral);
                    Conceito conceitoGeral;
                    if (mediaGeral < 2)
                    {
                        conceitoGeral = Conceito.E;
                        Console.WriteLine("O Conceito é: " + Conceito.E);
                    }
                    else if (mediaGeral < 4)
                    {
                        conceitoGeral = Conceito.D;
                        Console.WriteLine("O Conceito é: " + Conceito.D);
                    }
                    else if (mediaGeral < 6)
                    {
                        conceitoGeral = Conceito.C;
                        Console.WriteLine("O Conceito é: " + Conceito.C);
                    }
                    else if (mediaGeral < 8)
                    {
                        conceitoGeral = Conceito.B;
                        Console.WriteLine("O Conceito é: " + Conceito.B);
                    }
                    else
                    {
                        conceitoGeral = Conceito.A;
                        Console.WriteLine("O Conceito é: " + Conceito.A);
                    }


                    Console.WriteLine($"MÉDIA GERAL: {mediaGeral} - CONCEITO: {conceitoGeral}");

                    break;


                default:
                    throw new ArgumentOutOfRangeException(" ====== Opção Inválida!!! Tente Novamente!!! ====== ");
                }



                opcaoUsuario = ObterOpcaoUsuario();
            }
            if (opcaoUsuario == "X") //O X deverá ser digitado maiúsculo
            {
                Console.Write(" ... Saindo da Aplicação!!! ...");
                Console.WriteLine();
            }
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            Aluno[] alunos      = new Aluno[5];
            var     indiceAluno = 0;

            string opcao = ObterOpcao();

            while (opcao.ToUpper() != "X")
            {
                switch (opcao)
                {
                case "1":
                    //TO DO: adicionar aluno
                    Console.WriteLine("Informa o nome do aluno:");
                    Aluno aluno = new Aluno();
                    aluno.Nome = Console.ReadLine();

                    Console.WriteLine("Informe a nota do aluno:");

                    if (decimal.TryParse(Console.ReadLine(), out decimal nota))
                    {
                        aluno.Nota = nota;
                    }
                    else
                    {
                        throw new ArgumentException("O valor da nota deve ser decimal");
                    }


                    alunos[indiceAluno] = aluno;
                    indiceAluno++;
                    break;

                case "2":
                    //TO DO: listar alunos
                    foreach (var obj in alunos)
                    {
                        if (obj != null)
                        {
                            Console.WriteLine($"Aluno: {obj.Nome} - Nota: {obj.Nota}");
                        }
                    }
                    break;

                case "3":
                    //TO DO: Calcular média geral
                    decimal notaTotal = 0;
                    var     numAlunos = 0;
                    for (int i = 0; i < alunos.Length; i++)
                    {
                        if (alunos[i] != null)
                        {
                            notaTotal += alunos[i].Nota;
                            numAlunos++;
                        }
                    }

                    var mediaGeral = notaTotal / numAlunos;

                    Conceito conceitoGeral = 0;

                    if (mediaGeral < 2)
                    {
                        conceitoGeral = Conceito.E;
                    }
                    else if (mediaGeral >= 3 && mediaGeral < 4)
                    {
                        conceitoGeral = Conceito.D;
                    }
                    else if (mediaGeral >= 4 && mediaGeral < 6)
                    {
                        conceitoGeral = Conceito.C;
                    }
                    else if (mediaGeral >= 6 && mediaGeral < 8)
                    {
                        conceitoGeral = Conceito.B;
                    }
                    else if (mediaGeral >= 8)
                    {
                        conceitoGeral = Conceito.A;
                    }

                    Console.WriteLine($"Média geral dos alunos é: {mediaGeral} - Conceito: {conceitoGeral}");

                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
                opcao = ObterOpcao();
            }
        }
Esempio n. 4
0
        static void Main(string[] args)
        {
            Aluno[] alunos      = new Aluno[5];
            var     indiceAluno = 0;
            // Menu inicial
            string op = ObterOp();

            while (!op.Equals("X"))
            {
                switch (op)
                {
                case "1":
                    //TODO: adicionar aluno
                    Console.WriteLine("Informe o nome do aluno");
                    Aluno aluno = new Aluno();
                    aluno.nome = Console.ReadLine();
                    Console.WriteLine("Informe a nota do aluno");
                    // aluno.nota = decimal.Parse(Console.ReadLine()); dará erro se não for decimal
                    if (decimal.TryParse(Console.ReadLine(), out decimal nota))
                    {
                        aluno.nota = nota;
                    }
                    else
                    {
                        throw new ArgumentException("Valor da nota deve ser decimal");
                    }
                    alunos[indiceAluno] = aluno;
                    indiceAluno++;
                    break;

                case "2":
                    //TODO: listar alunos
                    foreach (var a in alunos)
                    {
                        if (!string.IsNullOrEmpty(a.nome))
                        {
                            Console.WriteLine($"ALUNO {a.nome} - NOTA {a.nota}");
                        }
                    }
                    break;

                case "3":
                    //TODO: Media geral
                    var     nralunos   = 0;
                    decimal mediaGeral = 0;
                    decimal notaTotal  = 0;
                    for (int i = 0; i < alunos.Length; i++)
                    {
                        if (!string.IsNullOrEmpty(alunos[i].nome))
                        {
                            notaTotal = notaTotal + alunos[i].nota;
                            nralunos++;
                        }
                    }
                    mediaGeral = notaTotal / nralunos;
                    ConceitoEnum conceitogeral;
                    if (mediaGeral <= 2)
                    {
                        conceitogeral = ConceitoEnum.E;
                    }
                    else if (mediaGeral <= 4)
                    {
                        conceitogeral = ConceitoEnum.D;
                    }
                    else if (mediaGeral <= 6)
                    {
                        conceitogeral = ConceitoEnum.C;
                    }
                    else if (mediaGeral <= 8)
                    {
                        conceitogeral = ConceitoEnum.B;
                    }
                    else
                    {
                        conceitogeral = ConceitoEnum.A;
                    }

                    Console.WriteLine($"Media Geral: {mediaGeral} conceito {conceitogeral}");
                    Console.WriteLine();
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
                op = ObterOp();
            }
        }
Esempio n. 5
0
        static void Main(string[] args)
        {
            Aluno[] alunos       = new Aluno[5];
            var     indiceAluno  = 0;
            string  opcaoUsuario = ObterOpcoesUsusario();

            while (opcaoUsuario.ToUpper() != "X")
            {
                switch (opcaoUsuario)
                {
                case "1":
                    Console.WriteLine("CADASTRO DE ALUNO");
                    Console.WriteLine("Digite o nome do Aluno");
                    Aluno aluno = new Aluno();
                    aluno.Nome = Console.ReadLine();
                    Console.WriteLine("Digite a note do Aluno");

                    if (Decimal.TryParse(Console.ReadLine(), out decimal nota))
                    {
                        aluno.Nota = nota;
                    }
                    else
                    {
                        throw new ArgumentException("O valor da nota deve ser decimal!");
                    }
                    if (indiceAluno < 5)
                    {
                        alunos[indiceAluno] = aluno;
                        indiceAluno++;
                    }
                    else
                    {
                        Console.WriteLine();
                        Console.WriteLine("NÚMERO MÁXIMO DE ALUNOS ATINGIDO!");
                        Console.WriteLine("NÃO É POSSÍVEL INCLUIR NOVOS ALUNOS!");
                    }


                    Console.WriteLine();
                    break;

                case "2":
                    Console.WriteLine("RELAÇÃO DE ALUNOS");
                    foreach (var a in alunos)
                    {
                        if (!string.IsNullOrEmpty(a.Nome))
                        {
                            Console.WriteLine($"Aluno: {a.Nome}, Nota {a.Nota}");
                        }
                    }
                    Console.WriteLine();
                    break;

                case "3":

                    decimal      notaTotal = 0;
                    var          nrAlunos  = 0;
                    ConceitoEnum conceitoGeral;
                    conceitoGeral = ConceitoEnum.A;

                    for (int i = 0; i < indiceAluno; i++)
                    {
                        if (!string.IsNullOrEmpty(alunos[i].Nome))
                        {
                            notaTotal = notaTotal + alunos[i].Nota;
                            nrAlunos++;
                        }
                    }

                    decimal mediaGeral = notaTotal / nrAlunos;


                    if (mediaGeral == 0)
                    {
                        conceitoGeral = ConceitoEnum.F;
                    }
                    else if (mediaGeral < 3)
                    {
                        conceitoGeral = ConceitoEnum.E;
                    }
                    else if (mediaGeral < 5)
                    {
                        conceitoGeral = ConceitoEnum.D;
                    }
                    else if (mediaGeral < 7)
                    {
                        conceitoGeral = ConceitoEnum.C;
                    }
                    else if (mediaGeral < 8)
                    {
                        conceitoGeral = ConceitoEnum.B;
                    }
                    else
                    {
                        conceitoGeral = ConceitoEnum.A;
                    }

                    Console.WriteLine("Média Geral = " + mediaGeral);
                    Console.WriteLine("Conceito Geral = " + conceitoGeral);
                    Console.WriteLine();
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }

                opcaoUsuario = ObterOpcoesUsusario();
            }
        }
Esempio n. 6
0
        static void Main(string[] args)
        {
            Aluno[] alunos       = new Aluno[5];
            var     indiceAluno  = 0;
            string  opcaoUsuario = ObterOpcaoUsuario();

            while (opcaoUsuario.ToUpper() != "X")
            {
                switch (opcaoUsuario)
                {
                case "1":
                    //adicionar alunos
                    Console.WriteLine("Informe o nome do aluno:");
                    Aluno aluno = new Aluno();
                    aluno.Nome = Console.ReadLine();

                    Console.WriteLine("Informe a nota do aluno:");
                    if (decimal.TryParse(Console.ReadLine(), out decimal nota))
                    {
                        aluno.Nota = nota;
                    }
                    else
                    {
                        throw new ArithmeticException("O valor da nota deve ser decimal");
                    }
                    alunos[indiceAluno] = aluno;
                    indiceAluno++;
                    break;

                case "2":
                    //listar alunos
                    foreach (var a1 in alunos)
                    {
                        if (!string.IsNullOrEmpty(a1.Nome))
                        {
                            Console.WriteLine($"Aluno: {a1.Nome} / Nota: {a1.Nota}");
                        }
                    }
                    break;

                case "3":
                    //calcular media geral
                    decimal notaTotal = 0;
                    var     nrAlunos  = 0;
                    for (int i = 0; i < alunos.Length; i++)
                    {
                        if (!string.IsNullOrEmpty(alunos[i].Nome))
                        {
                            notaTotal = notaTotal + alunos[i].Nota;
                            nrAlunos++;
                        }
                    }
                    var      medialGeral = notaTotal / nrAlunos;
                    Conceito conceitoGeral;

                    if (0 < medialGeral && medialGeral < 2)
                    {
                        conceitoGeral = Conceito.E;
                    }
                    else if (2 < medialGeral && medialGeral < 4)
                    {
                        conceitoGeral = Conceito.D;
                    }
                    else if (4 < medialGeral && medialGeral < 6)
                    {
                        conceitoGeral = Conceito.C;
                    }
                    else if (6 < medialGeral && medialGeral < 8)
                    {
                        conceitoGeral = Conceito.B;
                    }
                    else
                    {
                        conceitoGeral = Conceito.A;
                    }


                    Console.WriteLine($"Media geral {medialGeral} // Conceito {conceitoGeral}");

                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
                opcaoUsuario = ObterOpcaoUsuario();
            }
        }
Esempio n. 7
0
        static void Main(string[] args)
        {
            var    operacoes    = new Operacoes();
            string opcaoUsuario = ObterOpcaoUsuario();

            Aluno[] alunos      = new Aluno[1000];
            var     indiceAluno = 0;
            Aluno   aluno       = new Aluno();

            while (opcaoUsuario.ToUpper() != "X")
            {
                switch (opcaoUsuario)
                {
                case "1":
                    Console.WriteLine("Informe o nome do aluno");
                    aluno.nome = Console.ReadLine();
                    Random padraDaMatricula = new Random();
                    aluno.matricula = padraDaMatricula.Next(1000, 9999);


                    Console.WriteLine("Informe a nota do aluno");
                    if (decimal.TryParse(Console.ReadLine(), out decimal nota))
                    {
                        aluno.nota = nota;
                    }
                    else
                    {
                        Console.WriteLine("Opçao inválida.");
                    }
                    alunos[indiceAluno] = aluno;
                    indiceAluno++;
                    break;

                case "2":
                    foreach (var referenciaDoAluno in alunos)
                    {
                        if (!string.IsNullOrEmpty(referenciaDoAluno.nome))
                        {
                            {
                                Console.WriteLine($"Aluno {referenciaDoAluno.nome} - nota {referenciaDoAluno.nota} - Matricula {referenciaDoAluno.matricula}");
                            }
                        }
                    }
                    break;

                case "3":
                    decimal notaTotal      = 0;
                    var     numeroDeAlunos = 0;

                    for (int i = 0; i < alunos.Length; i++)
                    {
                        if (!string.IsNullOrWhiteSpace(alunos[i].nome))
                        {
                            notaTotal = notaTotal + alunos[i].nota;
                            numeroDeAlunos++;
                        }
                    }
                    var      mediaGeral = notaTotal / numeroDeAlunos;
                    Conceito conceitoGeral;

                    if (mediaGeral < 2)
                    {
                        conceitoGeral = Conceito.Pessimo;
                    }
                    else if (mediaGeral >= 2 && mediaGeral < 4)
                    {
                        conceitoGeral = Conceito.Ruim;
                    }
                    else if (mediaGeral >= 4 && mediaGeral < 6)
                    {
                        conceitoGeral = Conceito.Regular;
                    }
                    else if (mediaGeral >= 6 && mediaGeral < 8)
                    {
                        conceitoGeral = Conceito.Bom;
                    }
                    else
                    {
                        conceitoGeral = Conceito.Perfeito;
                    }

                    Console.WriteLine($"Media Geral: {mediaGeral} - conceito: {conceitoGeral}");
                    break;

                case "4":

                    Console.WriteLine("Informe o numero da matricula");
                    var numeroMatriculaDoAluno = Console.ReadLine();
                    var textoMatricula         = aluno.matricula.ToString();

                    if (numeroMatriculaDoAluno == textoMatricula)
                    {
                        if (aluno.nota < 6)
                        {
                            Console.WriteLine($"O aluno {aluno.nome} esta reprovado");
                        }
                        else if (aluno.nota == 6)
                        {
                            Console.WriteLine($"O aluno {aluno.nome} está em Recuperação");
                        }
                        else
                        {
                            Console.WriteLine($"O aluno {aluno.nome} esta aprovado");
                        }
                    }
                    break;


                default:
                    Console.WriteLine("Opçao inválida.");
                    break;
                }

                opcaoUsuario = ObterOpcaoUsuario();
            }
        }
Esempio n. 8
0
        static void Main(string[] args)
        {
            Aluno[] alunos      = new Aluno[5];
            var     indiceAluno = 0;
            string  escolha;

            escolha = ObterOpcaoUsuario();

            while (escolha.ToUpper() != "X")
            {
                switch (escolha)
                {
                case "1":
                    Console.WriteLine("Informe o nome do aluno:");
                    Aluno aluno = new Aluno();
                    aluno.Nome = Console.ReadLine();
                    Console.WriteLine("Informe a nota do aluno:");

                    if (decimal.TryParse(Console.ReadLine(), out decimal nota))
                    {
                        aluno.Nota = nota;
                    }
                    else
                    {
                        throw new ArgumentException("Valor da nota deve ser decimal");
                    }

                    alunos[indiceAluno] = aluno;
                    indiceAluno++;
                    break;

                case "2":
                    foreach (var a in alunos)
                    {
                        if (a.Nome != null)
                        {
                            Console.WriteLine($"Aluno: {a.Nome} - Nota: {a.Nota}");
                        }
                    }
                    break;

                case "3":
                    decimal notaTotal = 0;
                    var     nrAlunos  = 0;
                    foreach (var a in alunos)
                    {
                        if (!string.IsNullOrEmpty(a.Nome))
                        {
                            notaTotal = notaTotal + a.Nota;
                            nrAlunos++;
                        }
                    }

                    var mediaGeral = notaTotal / nrAlunos;
                    Console.WriteLine($"Média Geral: {mediaGeral}");

                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }

                escolha = ObterOpcaoUsuario();
            }
        }
Esempio n. 9
0
        static void Main(string[] args)
        {
            Aluno[] alunos       = new Aluno[5];
            var     indiceAluno  = 0;
            string  opcaoUsuario = obterOpcaoUsuario();

            while (opcaoUsuario.ToUpper() != "X")
            {
                switch (opcaoUsuario)
                {
                case "1":
                    Console.WriteLine("Informe o nome do aluno: ");
                    var aluno = new Aluno();
                    aluno.Nome = Console.ReadLine();
                    //aluno.Nome = Console.ReadLine(); Cannot implicitly convert type 'string' to 'int' [Revisao]csharp(CS0029)


                    Console.WriteLine("Informe a nota do aluno: ");

                    if (decimal.TryParse(Console.ReadLine(), out decimal nota))
                    {
                        //var Nota = nota;
                        aluno.Nota = nota;     //Cannot implicitly convert type 'decimal' to 'int'. An explicit conversion exists (are you missing a cast?) [Revisao]
                    }
                    else
                    {
                        throw new ArgumentException("Valor da nota de ser decimal");
                    }

                    alunos[indiceAluno] = aluno;
                    indiceAluno++;
                    //TODO: adicionar aluno
                    break;

                case "2":

                    foreach (var a in alunos)
                    {
                        if (!string.IsNullOrEmpty(a.Nome))
                        {
                            Console.WriteLine($"Aluno: {a.Nome} - NOTA: {a.Nota}");
                        }
                    }
                    //TODO: listar alunos
                    break;

                case "3":
                    decimal notaTotal = 0;
                    var     nrAlunos  = 0;
                    for (int i = 0; i < alunos.Length; i++)
                    {
                        if (!string.IsNullOrEmpty(alunos[i].Nome))
                        {
                            notaTotal = notaTotal + alunos[i].Nota;
                            nrAlunos++;
                        }
                    }

                    var      mediaGeral = notaTotal / nrAlunos;
                    Conceito conceitoGeral;


                    if (mediaGeral < 2)
                    {
                        conceitoGeral = Conceito.E;
                    }
                    else if (mediaGeral < 4)
                    {
                        conceitoGeral = Conceito.D;
                    }
                    else if (mediaGeral < 6)
                    {
                        conceitoGeral = Conceito.C;
                    }
                    else if (mediaGeral < 8)
                    {
                        conceitoGeral = Conceito.B;
                    }
                    else
                    {
                        conceitoGeral = Conceito.A;
                    }

                    Console.WriteLine($"MÉDIA GERAL: {mediaGeral} - CONCEITO: {conceitoGeral}");
                    //TODO: calcular media geral
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }

                opcaoUsuario = obterOpcaoUsuario();
            }
        }
Esempio n. 10
0
        static void Main(string[] args)
        {
            Aluno[] alunos      = new Aluno[5];
            int     indiceAluno = 0;
            string  opUsuario   = ObterOpcaoUsuario();

            while (opUsuario.ToUpper() != "X")
            {
                switch (opUsuario)
                {
                case "1":
                    Aluno aluno = new Aluno();
                    Console.Write("Informe o nome do aluno: ");
                    aluno.nome = Console.ReadLine();

                    Console.Write("Informe a nota do aluno " + aluno.nome + ": ");
                    if (decimal.TryParse(Console.ReadLine(), out decimal nota))
                    {
                        aluno.nota = nota;
                    }
                    else
                    {
                        throw new ArgumentException("O valor da nota deve ser decimal.");
                    }

                    alunos[indiceAluno] = aluno;
                    indiceAluno++;
                    break;

                case "2":
                    for (int i = 0; i < indiceAluno; i++)
                    {
                        Console.WriteLine($"Aluno: {alunos[i].nome} - Nota {alunos[i].nota} ");
                    }
                    Console.WriteLine();
                    break;

                case "3":
                    decimal media = 0;
                    for (int i = 0; i < indiceAluno; i++)
                    {
                        media += alunos[i].nota;
                    }
                    media = media / indiceAluno;

                    Conceito conceito;

                    if (media < 2)
                    {
                        conceito = Conceito.E;
                    }
                    else if (media < 4)
                    {
                        conceito = Conceito.D;
                    }
                    else if (media < 6)
                    {
                        conceito = Conceito.C;
                    }
                    else if (media < 8)
                    {
                        conceito = Conceito.B;
                    }
                    else
                    {
                        conceito = Conceito.A;
                    }

                    Console.WriteLine($"A média dos alunos é de: {media} - Conceito: {conceito}");

                    break;

                default:
                    throw new ArgumentOutOfRangeException("Informe um valor de 1 a 3.");
                }
                opUsuario = ObterOpcaoUsuario();
            }
        }
Esempio n. 11
0
        static void Main(string[] args)
        {
            Aluno[] alunos       = new Aluno[5];
            var     indiceAluno  = 0;
            string  opcaoUsuario = ObterOpcaoUsuario();

            while (opcaoUsuario.ToUpper() != "X")
            {
                switch (opcaoUsuario)
                {
                case "1":
                    /*TODO: Adicionar aluno*/
                    Console.WriteLine("Informe o nome do aluno:");
                    Aluno aluno = new Aluno();       /*Estancia o objeto aluno*/
                    aluno.Nome = Console.ReadLine(); /*Seta o nome do aluno*/

                    Console.WriteLine("Informe a nota do aluno:");

                    if (decimal.TryParse(Console.ReadLine(), out decimal nota))
                    {
                        aluno.Nota = nota;
                    }
                    else
                    {
                        throw new ArgumentException("Valor da nota deve ser decimal");
                    }
                    alunos[indiceAluno] = aluno;
                    indiceAluno++;
                    break;

                case "2":
                    /*TODO: Listar alunos*/
                    foreach (var A in alunos)
                    {
                        if (!String.IsNullOrEmpty(A.Nome)) /*!String.IsNullOrEmpty(A.Nome) vai mostrar apenas os alunos que não forem nulos os valores de nota*/
                        {
                            Console.WriteLine($"Aluno: {A.Nome} - Nota {A.Nota}");
                        }
                    }
                    break;

                case "3":
                    /*TODO: Calcular média geral*/
                    decimal notaTotal = 0;
                    var     nrAlunos  = 0;
                    for (int i = 0; i < alunos.Length; i++)
                    {
                        if (!String.IsNullOrEmpty(alunos[i].Nome))
                        {
                            notaTotal = notaTotal + alunos[i].Nota;
                            nrAlunos++;
                        }
                    }
                    var      mediaGeral = notaTotal / nrAlunos;
                    Conceito conceitoGeral;

                    if (mediaGeral < 2)
                    {
                        conceitoGeral = Conceito.E;
                    }
                    else if (mediaGeral < 4)
                    {
                        conceitoGeral = Conceito.D;
                    }
                    else if (mediaGeral < 6)
                    {
                        conceitoGeral = Conceito.C;
                    }
                    else if (mediaGeral < 8)
                    {
                        conceitoGeral = Conceito.D;
                    }
                    else if (mediaGeral < 10)
                    {
                        conceitoGeral = Conceito.B;
                    }
                    else
                    {
                        conceitoGeral = Conceito.A;
                    }
                    Console.WriteLine($"Média Geral: {mediaGeral} - Conceito: {conceitoGeral}");
                    break;

                default:
                    throw new ArgumentOutOfRangeException();     /* */
                }

                opcaoUsuario = ObterOpcaoUsuario();
            }
        }
Esempio n. 12
0
        static void Main(string[] args)
        {
            Aluno[] alunos       = new Aluno[5];
            var     indiceAluno  = 0;
            string  opcaoUsuario = ObterOpcaoUsuario();

            while (opcaoUsuario.ToUpper() != "X") // ToUpper() = vai pegar a letra do usuário e mudar para caixa alta
            {
                switch (opcaoUsuario)
                {
                case "1":
                    Console.WriteLine("Informe o nome do aluno:");
                    var aluno = new Aluno();         // instanciando um objeto aluno
                    aluno.Nome = Console.ReadLine(); // recebendo do usuário e atribuindo ao objeto aluno

                    Console.WriteLine("Informe a nota do aluno:");

                    if (decimal.TryParse(Console.ReadLine(), out decimal nota))
                    // TryParse = indica que pode ou não fazer o 'Parse'
                    // Caso o TryParse consiga fazer a consversão, ele já atribui o valor para a variavel nota
                    {
                        aluno.Nota = nota;
                    }
                    else
                    {
                        throw new ArgumentException("O valor da nota deve ser em decimal");
                    }
                    // Atribuindo o objeto 'aluno' que foi criado na posição do array 'alunos[]'
                    // indicada pelo 'indiceAluno'
                    alunos[indiceAluno] = aluno;
                    indiceAluno++;
                    break;

                case "2":
                    // foreach = Para cada 'ListaAluno' no meu array 'alunos' faça...
                    foreach (var listaAluno in alunos)
                    {
                        if (!string.IsNullOrEmpty(listaAluno.Nome))
                        // ! = nega a condição, se o 'Nome' for diferente de nulo ou vazio faça...
                        {
                            // $ = string interpolation, para facilitar a concatenação
                            Console.WriteLine($"ALUNO: {listaAluno.Nome} - NOTA: {listaAluno.Nota}");
                        }
                    }
                    break;

                case "3":
                    decimal notaTotal = 0;
                    var     nrAlunos  = 0;

                    for (var i = 0; i < alunos.Length; i++)
                    {
                        if (!string.IsNullOrEmpty(alunos[i].Nome))
                        {
                            notaTotal = notaTotal + alunos[i].Nota;
                            nrAlunos++;
                        }
                    }

                    var          mediaGeral = notaTotal / nrAlunos;
                    ConceitoEnum conceitoGeral;

                    if (mediaGeral <= 2)
                    {
                        conceitoGeral = ConceitoEnum.E;
                    }
                    else if (mediaGeral <= 4)
                    {
                        conceitoGeral = ConceitoEnum.D;
                    }
                    else if (mediaGeral <= 6)
                    {
                        conceitoGeral = ConceitoEnum.C;
                    }
                    else if (mediaGeral < 10)
                    {
                        conceitoGeral = ConceitoEnum.B;
                    }
                    else
                    {
                        conceitoGeral = ConceitoEnum.A;
                    }
                    Console.WriteLine($"MÉDIA GERAL: {mediaGeral} - CONCEITO GERAL: {conceitoGeral}");

                    break;

                default:
                    throw new ArgumentOutOfRangeException();     // Vai disparar uma exeção indicando que o valor informado
                                                                 // esta fora das opções
                }

                opcaoUsuario = ObterOpcaoUsuario();
            }
        }
Esempio n. 13
0
        static void Main(string[] args)
        {
            Aluno[] alunos       = new Aluno[5];
            var     indeceAluno  = 0;
            string  opcaoUsuario = ObterOpcaoUsuario();

            while (opcaoUsuario.ToUpper() != "X")
            {
                switch (opcaoUsuario)
                {
                case "1":
                    Console.WriteLine("Informe o nome do aluno:");
                    var aluno = new Aluno();
                    aluno.Nome = Console.ReadLine();

                    Console.WriteLine("Informe a nota do aluno:");
                    if (decimal.TryParse(Console.ReadLine(), out decimal nota))
                    {
                        aluno.Nota = nota;
                    }
                    else
                    {
                        throw new ArgumentException("Valor da nota deve ser decimal!");
                    }

                    alunos [indeceAluno] = aluno;
                    indeceAluno++;

                    break;

                case "2":
                    foreach (var i in alunos)
                    {
                        if (!string.IsNullOrEmpty(i.Nome))   //negação da string for nul ou vazia
                        {
                            Console.WriteLine($"Aluno: {i.Nome} - Nota: {i.Nota}");
                        }
                    }
                    break;

                case "3":
                    decimal notaTotal = 0;
                    int     qtdAlunos = 0;

                    for (int i = 0; i < alunos.Length; i++)
                    {
                        if (!string.IsNullOrEmpty(alunos[i].Nome))
                        {
                            notaTotal = notaTotal + alunos[i].Nota;
                            qtdAlunos++;
                        }
                    }
                    var mediaGeral = notaTotal / qtdAlunos;        //dividindo a nota geral

                    EConceito conceitoGeral;

                    if (mediaGeral < 2)
                    {
                        conceitoGeral = EConceito.E;
                    }
                    else if (mediaGeral < 4)
                    {
                        conceitoGeral = EConceito.D;
                    }
                    else if (mediaGeral < 6)
                    {
                        conceitoGeral = EConceito.C;
                    }
                    else if (mediaGeral < 8)
                    {
                        conceitoGeral = EConceito.B;
                    }
                    else
                    {
                        conceitoGeral = EConceito.A;
                    }

                    Console.WriteLine($"Média Geral: {mediaGeral} - Conceito: {conceitoGeral}");

                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }

                opcaoUsuario = ObterOpcaoUsuario();
            }
        }
Esempio n. 14
0
        static void Main(string[] args)
        {
            Console.Clear();

            Aluno[] alunos      = new Aluno[5];
            var     indiceAluno = 0;

            var opcaoUsuario = ObterOpcaoUsuario();

            while (opcaoUsuario.ToUpper() != "X")
            {
                switch (opcaoUsuario)
                {
                case "1":
                    Console.WriteLine("Informe o nome do aluno:");
                    Aluno aluno = new Aluno();
                    aluno.Nome = Console.ReadLine();

                    Console.WriteLine("Informe a nota do aluno:");

                    if (decimal.TryParse(Console.ReadLine(), out decimal nota))
                    {
                        aluno.Nota = nota;
                    }
                    else
                    {
                        throw new ArgumentException("Valor da nota deve ser decimal");
                    }

                    alunos[indiceAluno] = aluno;
                    indiceAluno++;

                    break;

                case "2":

                    foreach (var a in alunos)
                    {
                        if (a != null)
                        {
                            Console.WriteLine($"ALUNO: {a.Nome} - NOTA: {a.Nota} ");
                        }
                    }
                    break;

                case "3":
                    decimal  notaTotal       = 0;
                    decimal  media           = 0;
                    var      qtdAlunos       = 0;
                    Conceito conceitoGeral   = Conceito.E;
                    int      mediaAproximada = 0;

                    for (int i = 0; i < (alunos.Length - 1); i++)
                    {
                        if (alunos[i] != null)
                        {
                            notaTotal += alunos[i].Nota;
                            qtdAlunos++;
                        }
                    }

                    if (qtdAlunos > 0)
                    {
                        media = notaTotal / qtdAlunos;
                    }

                    mediaAproximada = Convert.ToInt32(media);

                    switch (mediaAproximada)
                    {
                    case 10:
                        conceitoGeral = Conceito.A;
                        break;

                    case 9:
                        conceitoGeral = Conceito.A;
                        break;

                    case 8:
                        conceitoGeral = Conceito.B;
                        break;

                    case 7:
                        conceitoGeral = Conceito.B;
                        break;

                    case 6:
                        conceitoGeral = Conceito.C;
                        break;

                    case 5:
                        conceitoGeral = Conceito.C;
                        break;

                    case 4:
                        conceitoGeral = Conceito.E;
                        break;

                    case 3:
                        conceitoGeral = Conceito.E;
                        break;

                    case 2:
                        conceitoGeral = Conceito.E;
                        break;

                    case 1:
                        conceitoGeral = Conceito.E;
                        break;

                    case 0:
                        conceitoGeral = Conceito.E;
                        break;
                    }

                    Console.WriteLine(value: $"MÉDIA GERAL : {media} CONCEITO GERAL : {conceitoGeral} ");
                    break;

                default:
                    throw new ArgumentOutOfRangeException("Você informou uma opção inválida.");
                }
                opcaoUsuario = ObterOpcaoUsuario();
            }

            Console.Clear();
        }
Esempio n. 15
0
        static void Main(string[] args)
        {
            Aluno[] alunos        = new Aluno[5];
            var     indiceAluno   = 0;
            string  opcaoUusuario = obterOpcaoUsuario();

            while (opcaoUusuario.ToUpper() != "X")
            {
                switch (opcaoUusuario)
                {
                case "1":
                    Console.WriteLine("Informe ai o nome do aluno");
                    Aluno aluno = new Aluno();
                    aluno.Nome = Console.ReadLine();

                    Console.WriteLine("Informe ai nota do aluno");

                    if (decimal.TryParse(Console.ReadLine(), out decimal nota))
                    {
                        aluno.Nota = nota;
                    }
                    else
                    {
                        throw new ArgumentException("O valor da nota deve ser decimal");
                    }


                    alunos[indiceAluno] = aluno;
                    indiceAluno++;
                    break;

                case "2":
                    foreach (var a in alunos)
                    {
                        //se  o nome não for nulo nem falso executa
                        if (!string.IsNullOrEmpty(a.Nome))
                        {
                            Console.WriteLine($"ALUNO: {a.Nome} - NOTA: {a.Nota}");
                        }
                    }
                    break;

                case "3":
                    decimal notaTotal = 0;
                    var     nrAlunos  = 0;

                    for (int i = 0; i < alunos.Length; i++)
                    {
                        if (!string.IsNullOrEmpty(alunos[i].Nome))
                        {
                            notaTotal = notaTotal + alunos[i].Nota;
                            nrAlunos++;
                        }
                    }

                    var mediaGeral = notaTotal / nrAlunos;
                    Console.WriteLine($"Media geral: {mediaGeral}");
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }



                opcaoUusuario = obterOpcaoUsuario();
            }
        }
        static void Main(string[] args)
        {
            Aluno[] listaAlunos = new Aluno[5]; //cria o array com 5 posicoes
            var     indiceAluno = 0;

            string opcaoUsuario = ObterOpcaoUsuario();

            while (opcaoUsuario.ToUpper() != "X")
            {
                switch (opcaoUsuario)
                {
                case "1":
                    Console.WriteLine("Informe o nome do aluno: ");
                    var aluno = new Aluno();     //intancia a classe aluno e atribui o valor para a variavel aluno

                    aluno.Nome = Console.ReadLine();

                    Console.WriteLine("Informe a nota do aluno: ");

                    if (decimal.TryParse(Console.ReadLine(), out decimal nota))      //Se o TryParse conseguir converter a note para decimal, ele preenche a variavel note, caso contrário define false e vai para o else
                    {
                        aluno.Nota = nota;
                    }
                    else
                    {
                        throw new ArgumentException("O valor da nota precisa ser decimal");
                    }

                    listaAlunos[indiceAluno] = aluno;
                    indiceAluno++;

                    break;

                case "2":
                    foreach (var membro in listaAlunos)
                    {
                        if (!string.IsNullOrEmpty(membro.Nome))     // se a string nome não for vazio ou nulo, pode imprimir
                        {
                            Console.WriteLine($"ALUNO: {membro.Nome} - NOTA: {membro.Nota}");
                        }
                    }

                    break;

                case "3":
                    decimal notaTotal   = 0;
                    var     alunosTotal = 0;

                    for (int i = 0; i < listaAlunos.Length; i++)
                    {
                        if (!string.IsNullOrEmpty(listaAlunos[i].Nome))
                        {
                            notaTotal = notaTotal + listaAlunos[i].Nota;
                            alunosTotal++;
                        }
                    }

                    var mediaGeral = notaTotal / alunosTotal;
                    Console.WriteLine($"MEDIA GERAL: {mediaGeral}");

                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }

                opcaoUsuario = ObterOpcaoUsuario();
            }
        }
        static void Main(string[] args)
        {
            Aluno[] alunos      = new Aluno[5];
            int     indiceAluno = 0;

            string opcaoUsuario = ObterOpcaoUsuario();

            while (opcaoUsuario.ToUpper() != "X")
            {
                switch (opcaoUsuario)
                {
                case "1":
                    //TODO: Adicionar aluno
                    Console.WriteLine("Informe o nome do aluno:");
                    Aluno aluno = new Aluno();
                    aluno.Nome = Console.ReadLine();
                    Console.WriteLine("Informe a nota do aluno:");
                    if (decimal.TryParse(Console.ReadLine(), out decimal nota))
                    {
                        aluno.Nota = nota;
                    }
                    else
                    {
                        throw new ArgumentException("O valor da nota deve ser decimal");
                    }
                    alunos[indiceAluno] = aluno;
                    indiceAluno++;


                    break;

                case "2":
                    //TODO: listar alunos
                    foreach (var a in alunos)
                    {
                        if (a.Nome != null)
                        {
                            Console.WriteLine($"Aluno: {a.Nome}  -  Nota: {a.Nota}");
                        }
                    }
                    break;

                case "3":
                    //TODO: calcular média geral
                    decimal notaTotal = 0;
                    decimal nrAlunos  = 0;


                    for (int i = 0; i < alunos.Length; i++)
                    {
                        if (alunos[i].Nome != null)
                        {
                            notaTotal += alunos[i].Nota;
                            nrAlunos++;
                        }
                    }

                    decimal      mediaGeral = notaTotal / nrAlunos;
                    ConceitoEnum conceitoGeral;
                    if (mediaGeral < 2)
                    {
                        conceitoGeral = ConceitoEnum.E;
                    }
                    else if (mediaGeral < 4)
                    {
                        conceitoGeral = ConceitoEnum.D;
                    }
                    else if (mediaGeral < 6)
                    {
                        conceitoGeral = ConceitoEnum.C;
                    }
                    else if (mediaGeral < 8)
                    {
                        conceitoGeral = ConceitoEnum.B;
                    }
                    else
                    {
                        conceitoGeral = ConceitoEnum.A;
                    }

                    Console.WriteLine($"Média Geral: {mediaGeral} - Conceito Geral: {conceitoGeral}");
                    break;

                default:
                    throw new ArgumentException();
                }

                opcaoUsuario = ObterOpcaoUsuario();
            }
        }
Esempio n. 18
0
        static void Main(string[] args)
        {
            Aluno[] alunos       = new Aluno[5];
            var     indiceAluno  = 0;
            string  opcaoUsuario = ObterOpcaoUsuario();

            while (opcaoUsuario.ToUpper() != "X")
            {
                switch (opcaoUsuario)
                {
                case "1":
                    //TODO: Adicionar Aluno
                    Console.WriteLine("Informe o nome do aluno: ");
                    Aluno aluno = new Aluno();
                    aluno.Nome = Console.ReadLine();

                    Console.WriteLine("Informe a nota do aluno: ");

                    if (decimal.TryParse(Console.ReadLine(), out decimal nota))
                    {
                        aluno.Nota = nota;
                    }
                    else
                    {
                        throw new ArgumentOutOfRangeException("O valor da nota deve ser um decimal!!!");
                    }
                    alunos[indiceAluno] = aluno;
                    indiceAluno++;

                    break;

                case "2":
                    // TODO: Listar Alunos

                    foreach (var a in alunos)
                    {
                        Console.WriteLine($"ALUNO: {a.Nome} - NOTA: {a.Nota}");
                    }
                    break;

                case "3":
                    //TODO: Calcular Média Geral

                    decimal notaTotal = 0;
                    var     nrAlunos  = 0;
                    for (int i = 0; i < alunos.Length; i++)
                    {
                        if (!string.IsNullOrEmpty(alunos[i].Nome))
                        {
                            notaTotal = notaTotal + alunos[i].Nota;
                            nrAlunos++;
                        }
                    }

                    var mediaGeral = notaTotal / nrAlunos;
                    Console.WriteLine($"MÉDIA GERAL: {mediaGeral}");

                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }

                opcaoUsuario = ObterOpcaoUsuario();
            }
        }
Esempio n. 19
0
        static void Main(string[] args)
        {
            Aluno[] alunos       = new Aluno[5];
            var     indiceAluno  = 0;
            string  opcaoUsuario = ObterOpcaoUsuario();

            while (opcaoUsuario.ToUpper() != "X")
            {
                switch (opcaoUsuario)
                {
                case "1":
                    Console.WriteLine("Informe o nome do aluno:");
                    Aluno aluno = new Aluno();
                    aluno.Nome = Console.ReadLine();

                    Console.WriteLine("Informe a nota do aluno:");

                    if (decimal.TryParse(Console.ReadLine(), out decimal nota))
                    {
                        aluno.Nota = nota;
                    }
                    else
                    {
                        throw new ArithmeticException("Valor da nota deve ser decimal");
                    }

                    alunos[indiceAluno] = aluno;
                    indiceAluno++;

                    break;

                case "2":
                    foreach (var a in alunos)
                    {
                        if (!string.IsNullOrEmpty(a.Nome))
                        {
                            Console.WriteLine($"ALUNO: {a.Nome} . NOTA: {a.Nota}");
                        }
                    }
                    break;

                case "3":
                    decimal notaTotal = 0;
                    var     nrAlunos  = 0;
                    for (int i = 0; i < alunos.Length; i++)
                    {
                        if (!string.IsNullOrEmpty(alunos[i].Nome))
                        {
                            notaTotal = notaTotal + alunos[i].Nota;
                        }
                    }
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }

                Console.WriteLine("Informe a opção desejada:");
                Console.WriteLine("1 - Inserir nome de aluno");
                Console.WriteLine("2 - Listar alunos:");
                Console.WriteLine("3 - Calcular média geral:");
                Console.WriteLine("X - Sair");
                Console.WriteLine();

                opcaoUsuario = ObterOpcaoUsuario();
            }
        }
Esempio n. 20
0
        static void Main(string[] args)
        {
            Aluno[] alunos       = new Aluno[5];
            var     indice       = 0;
            string  opcaousuario = ObterOpcaoUsuario();

            while (opcaousuario.ToUpper() != "x")
            {
                switch (opcaousuario)
                {
                case "1":

                    //TODO: ADICIONAR ALUNOS
                    Console.WriteLine("Informe o nome do Aluno:");
                    Aluno aluno = new Aluno();
                    aluno.nome = Console.ReadLine();

                    Console.WriteLine("Informe a nota do aluno:");
                    if (decimal.TryParse(Console.ReadLine(), out decimal nota))
                    {    //o tryparse verifica se o valor é possivel de converter e já declara uma variável, que no caso é nota
                        aluno.nota = nota;
                    }
                    else
                    {
                        throw new ArgumentException("Valor da Nora tem que ser Decimal");
                    }

                    alunos[indice] = aluno;
                    indice++;

                    break;

                case "2":
                    //TODO: LISTAR ALUNOS

                    foreach (var a  in alunos)
                    {
                        if (!string.IsNullOrEmpty(a.nome))   //se o nome não for vazio ele retorna true ou false
                        {
                            Console.WriteLine($"Aluno: {a.nome} - Nota: {a.nota}");
                        }
                    }

                    break;

                case "3":
                    //TODO: CALCULAR MÉDIA GERAL
                    decimal nota_total = 0;
                    var     numAlunos  = 0;

                    for (int i = 0; i < alunos.Length; i++)
                    {
                        if (!string.IsNullOrEmpty(alunos[i].nome))
                        {
                            nota_total += alunos[i].nota;
                            numAlunos++;
                        }
                    }

                    var          mediaGeral = nota_total / numAlunos;
                    ConceitoEnum conceitoGeral;

                    if (mediaGeral < 2)
                    {
                        conceitoGeral = ConceitoEnum.E;
                    }
                    else if (mediaGeral < 4)
                    {
                        conceitoGeral = ConceitoEnum.D;
                    }
                    else if (mediaGeral < 6)
                    {
                        conceitoGeral = ConceitoEnum.C;
                    }
                    else if (mediaGeral < 8)
                    {
                        conceitoGeral = ConceitoEnum.B;
                    }
                    else
                    {
                        conceitoGeral = ConceitoEnum.A;
                    }

                    Console.WriteLine($"Media Geral: {mediaGeral} - Conceito: {conceitoGeral}");

                    break;

                default:

                    throw new ArgumentOutOfRangeException();
                }

                opcaousuario = ObterOpcaoUsuario();
            }
        }
        static void Main(string[] args)
        {
            Aluno[] alunos       = new Aluno[5];
            var     indiceAluno  = 0;
            string  opcaoUsuario = ObterOpcaoUsuario();

            while (opcaoUsuario.ToUpper() != "X") //mesmo se o usuario utiliza letra minuscula vai haver tratamento da string
            {
                switch (opcaoUsuario)
                {
                case "1":
                    Console.WriteLine("Informe o nome do Aluno:");
                    Aluno aluno = new Aluno();
                    aluno.Nome = Console.ReadLine();

                    Console.WriteLine("Informe a nota do Aluno:");

                    if (decimal.TryParse(Console.ReadLine(), out decimal nota))
                    {
                        aluno.Nota = nota;
                    }
                    else
                    {
                        throw new ArgumentOutOfRangeException("Valor da nota deve ser decimal");
                    }

                    alunos[indiceAluno] = aluno;
                    indiceAluno++;     //incrementa para que o proximo aluno ele já vá pra próxima casa no array;

                    break;

                case "2":
                    foreach (var a in alunos)
                    {
                        if (!string.IsNullOrEmpty(a.Nome))
                        {
                            Console.WriteLine($"ALUNO: {a.Nome} - NOTA: {a.Nota}");     //usando o objeto "a" pra cada aluno imprime o nome do aluno e a nota
                        }
                    }

                    break;

                case "3":
                    decimal notaTotal = 0;
                    var     nrALunos  = 0;

                    for (int i = 0; i < alunos.Length; i++)
                    {
                        if (!string.IsNullOrEmpty(alunos[i].Nome))
                        {
                            notaTotal = notaTotal + alunos[i].Nota;
                            nrALunos++;
                        }
                    }

                    var mediaGeral = notaTotal / nrALunos;

                    ConceitoEnum conceitoGeral;

                    if (mediaGeral <= 2)
                    {
                        conceitoGeral = ConceitoEnum.E;
                    }
                    else if (mediaGeral <= 4)
                    {
                        conceitoGeral = ConceitoEnum.D;
                    }
                    else if (mediaGeral <= 6)
                    {
                        conceitoGeral = ConceitoEnum.C;
                    }
                    else if (mediaGeral <= 8)
                    {
                        conceitoGeral = ConceitoEnum.B;
                    }
                    else
                    {
                        conceitoGeral = ConceitoEnum.A;
                    }


                    Console.WriteLine($"MÉDIA GERAL: {mediaGeral} - CONCEITO {conceitoGeral}");


                    break;

                default:

                    throw new ArgumentOutOfRangeException();     //Vai disparar uma excesao está fora do range de opçoes.
                }


                opcaoUsuario = ObterOpcaoUsuario();
            }
        }
Esempio n. 22
0
        static void Main(string[] args)
        {
            Aluno[] alunos       = new Aluno[5];
            int     indiceAluno  = 0;
            string  opcaoUsuario = obterOpcaoUsuario();

            while (opcaoUsuario.ToUpper() != "X")
            {
                // if (opcaoUsuario == "1")
                // {
                //     Console.ReadKey();
                // }
                // else if (opcaoUsuario == "2")
                // {

                // }
                // else if (opcaoUsuario == "3")
                // {

                // }
                // else
                // {
                //     Console.WriteLine("Slecione 1, 2, 3 ou X");
                //     Console.WriteLine("1 - Inserir novo aluno");
                //     Console.WriteLine("2 - Listar alunos");
                //     Console.WriteLine("3 - Calcular media geral");
                //     Console.WriteLine("X - Sair\n");
                //     Console.ReadLine();
                //         if (opcaoUsuario == "1")
                //         {

                //         }
                //         else if (opcaoUsuario == "2")
                //         {

                //         }
                //         else if (opcaoUsuario == "3")
                //         {

                //         }
                //         else if (opcaoUsuario.ToUpper() == "x")
                //         {
                //             break;
                //         }
                // }
                switch (opcaoUsuario)
                {
                case "1":
                    //adicionar aluno
                    Console.WriteLine("Informe o nome do aluno: ");
                    Aluno aluno = new Aluno();
                    aluno.Nome = Console.ReadLine();
nota:
                    Console.WriteLine("Informe a nota do aluno: ");

                    if (decimal.TryParse(Console.ReadLine(), out decimal nota))
                    {
                        aluno.Nota = nota;
                        Console.WriteLine();
                    }
                    else
                    {
                        Console.WriteLine("Coloque uma nota existente.");
                        goto nota;
                    }
                    if (indiceAluno < alunos.Length)
                    {
                        alunos[indiceAluno] = aluno;
                        indiceAluno++;
                    }
                    else
                    {
                        Console.WriteLine("Não cabem mais alunos");
                    }


                    break;

                case "2":
                    //listar aluno
                    foreach (var a in alunos)
                    {
                        if (a.Nome != null)
                        {
                            Console.WriteLine($"ALUNO: {a.Nome} - NOTA: {a.Nota}");
                            //Console.WriteLine(a.nome);
                        }
                    }
                    Console.WriteLine();
                    break;

                case "3":
                    //media geral
                    decimal notaTotal = 0;
                    var     nmrAlunos = 0;
                    decimal resulado  = 0;

                    for (int i = 0; i < alunos.Length; i++)
                    {
                        if (alunos[i].Nome != null)
                        {
                            notaTotal = notaTotal + alunos[i].Nota;
                            nmrAlunos++;
                        }
                    }
                    resulado = notaTotal / nmrAlunos;
                    ConceitoEnum conceitoGeral;

                    if (resulado < 2)
                    {
                        conceitoGeral = ConceitoEnum.E;
                    }
                    else if (resulado < 4)
                    {
                        conceitoGeral = ConceitoEnum.D;
                    }
                    else if (resulado < 6)
                    {
                        conceitoGeral = ConceitoEnum.C;
                    }
                    else if (resulado < 8)
                    {
                        conceitoGeral = ConceitoEnum.B;
                    }
                    else
                    {
                        conceitoGeral = ConceitoEnum.A;
                    }


                    Console.WriteLine($"Media: {resulado} - Conceito: {conceitoGeral}");
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
                opcaoUsuario = obterOpcaoUsuario();
            }
        }
Esempio n. 23
0
        static void Main(string[] args)
        {
            Aluno[] alunos       = new Aluno[5];
            var     indiceAluno  = 0;
            string  opcaoUsuario = ObterOpcaoUsuario();

            while (opcaoUsuario.ToUpper() != "X")
            {
                switch (opcaoUsuario)
                {
                case "1":
                    Console.WriteLine("Informe o nome do aluno: ");
                    var aluno = new Aluno();
                    aluno.Nome = Console.ReadLine();

                    Console.WriteLine("Informe a nota do aluno: ");

                    if (decimal.TryParse(Console.ReadLine(), out decimal nota))
                    {
                        aluno.Nota = nota;
                    }
                    else
                    {
                        throw new ArgumentException("O valor da nota deve ser decimal");
                    }

                    alunos[indiceAluno] = aluno;     // aqui joga o dado aluno recebido no terminal para o Array
                    indiceAluno++;
                    break;

                case "2":
                    //TODO: LISTAR ALUNOS
                    foreach (var student in alunos)
                    {
                        /* if (!student.Nome.Equals("")) */     //Se o nome NAO FOR vazio ai imprime o nome e nota do aluno
                        if (!string.IsNullOrEmpty(student.Nome))
                        {
                            Console.WriteLine($"ALUNO: {student.Nome} - NOTA: {student.Nota}");
                        }
                    }
                    break;

                case "3":
                    //TODO: Calcular MEDIA GERAL
                    decimal notaTotal = 0;
                    var     nrAlunos  = 0;

                    for (int i = 0; i < alunos.Length; i++)
                    {
                        if (!string.IsNullOrEmpty(alunos[i].Nome))
                        {
                            notaTotal = notaTotal + alunos[i].Nota;
                            nrAlunos++;
                        }
                    }

                    var      mediaGeral = notaTotal / nrAlunos;
                    Conceito conceitoGeral;

                    if (mediaGeral < 2)
                    {
                        conceitoGeral = Conceito.E;
                    }
                    else if (mediaGeral < 4)
                    {
                        conceitoGeral = Conceito.D;
                    }
                    else if (mediaGeral < 6)
                    {
                        conceitoGeral = Conceito.C;
                    }
                    else if (mediaGeral < 8)
                    {
                        conceitoGeral = Conceito.B;
                    }
                    else
                    {
                        conceitoGeral = Conceito.A;
                    }

                    Console.WriteLine($"MEDIA GERAL {mediaGeral} - CONCEITO {conceitoGeral}");

                    break;

                default:
                    throw new ArgumentOutOfRangeException("Digite uma opcao valida");
                }
                Console.WriteLine();

                opcaoUsuario = ObterOpcaoUsuario();
            }
        }
Esempio n. 24
0
        static void Main(string[] args)
        {
            //cria vetor alunos do tipo Aluno

            Aluno[] alunos       = new Aluno[5];
            var     indiceAlunos = 0;

            string opcaoUsuario = OpcaoUsuario();

            while (opcaoUsuario.ToUpper() != "X")
            {
                switch (opcaoUsuario)
                {
                case "1":

                    Console.WriteLine("Informe o nome do aluno: ");

                    Aluno aluno = new Aluno();
                    aluno.Nome = Console.ReadLine();

                    Console.WriteLine("Digite a nota do aluno: ");

                    if (decimal.TryParse(Console.ReadLine(), out decimal nota))
                    {
                        aluno.Nota = nota;
                    }
                    else
                    {
                        throw new ArgumentException("Valor da nota deve ser decimal!");
                    }

                    alunos[indiceAlunos] = aluno;

                    indiceAlunos++;

                    break;

                case "2":

                    foreach (var a in alunos)
                    {
                        if (!string.IsNullOrEmpty(a.Nome))
                        {
                            Console.WriteLine($"ALUNO = {a.Nome} - NOTA = {a.Nota}");
                        }
                    }

                    break;

                case "3":

                    decimal  media      = 0;
                    int      qtdeAlunos = 0;
                    Conceito conceito;

                    for (int i = 0; i < alunos.Length; i++)
                    {
                        if (!string.IsNullOrEmpty(alunos[i].Nome))
                        {
                            media += alunos[i].Nota;
                            qtdeAlunos++;
                        }
                    }

                    media /= qtdeAlunos;

                    if (media < 2)
                    {
                        conceito = Conceito.E;
                    }
                    if (media < 4)
                    {
                        conceito = Conceito.D;
                    }
                    if (media < 6)
                    {
                        conceito = Conceito.C;
                    }
                    if (media < 8)
                    {
                        conceito = Conceito.B;
                    }
                    else
                    {
                        conceito = Conceito.A;
                    }

                    Console.WriteLine($"MÉDIA = {media} - CONCEITO = {conceito}");

                    break;

                default:

                    throw new ArgumentOutOfRangeException();
                }
                opcaoUsuario = OpcaoUsuario();
            }
        }
Esempio n. 25
0
        static void Main(string[] args)
        {
            Aluno[] alunos       = new Aluno[5];
            int     indiceAluno  = 0;
            string  opcaoUsuario = ObterOpcaoUsuario();

            while (opcaoUsuario.ToUpper() != "X")
            {
                switch (opcaoUsuario)
                {
                case "1":
                    Console.WriteLine("Informe o nome do aluno:");
                    Aluno aluno = new Aluno();
                    aluno.Nome = Console.ReadLine();

                    Console.WriteLine("Informe a nota do aluno:");

                    if (decimal.TryParse(Console.ReadLine(), out decimal nota))
                    {
                        aluno.Nota = nota;
                    }
                    else
                    {
                        throw new ArgumentException("Valor da nota deve ser decimal");
                    }

                    alunos[indiceAluno] = aluno;
                    indiceAluno++;

                    break;

                case "2":
                    foreach (var a in alunos)
                    {
                        if (!string.IsNullOrEmpty(a.Nome))
                        {
                            Console.WriteLine($"ALUNO: {a.Nome} - NOTA: {a.Nota}");
                        }
                    }
                    break;

                case "3":
                    decimal notaTotal = 0;
                    var     nrAlunos  = 0;

                    for (int i = 0; i < alunos.Length; i++)
                    {
                        if (!string.IsNullOrEmpty(alunos[i].Nome))
                        {
                            notaTotal = notaTotal + alunos[i].Nota;
                            nrAlunos++;
                        }
                    }

                    var          mediaGeral = notaTotal / nrAlunos;
                    ConceitoEnum conceitoGeral;

                    if (mediaGeral < 2)
                    {
                        conceitoGeral = ConceitoEnum.E;
                    }
                    else if (mediaGeral < 4)
                    {
                        conceitoGeral = ConceitoEnum.D;
                    }
                    else if (mediaGeral < 6)
                    {
                        conceitoGeral = ConceitoEnum.C;
                    }
                    else if (mediaGeral < 8)
                    {
                        conceitoGeral = ConceitoEnum.B;
                    }
                    else
                    {
                        conceitoGeral = ConceitoEnum.A;
                    }

                    Console.WriteLine($"MÉDIA GERAL: {mediaGeral} - CONCEITO: {conceitoGeral}");


                    Console.WriteLine($"MÉDIA GERAL: {mediaGeral}");
                    break;

                default:

                    throw new ArgumentOutOfRangeException();
                }

                opcaoUsuario = ObterOpcaoUsuario();
            }
        }
        static void Main(string[] args)
        {
            Aluno[] alunos       = new Aluno[5];
            int     indiceAluno  = 0;
            string  opcaoUsuario = ObterOpcaoUsuario();

            while (opcaoUsuario.ToUpper() != "X")
            {
                switch (opcaoUsuario)
                {
                case "1":
                    Console.WriteLine("Informe o nome do aluno:");
                    Aluno aluno = new Aluno();
                    aluno.Nome = Console.ReadLine();

                    Console.WriteLine("Informe a nota do aluno:");

                    if (decimal.TryParse(Console.ReadLine(), out decimal nota))
                    {
                        aluno.Nota = nota;
                    }
                    else
                    {
                        throw new ArgumentException("O valor da nota deve ser decimal");
                    }

                    alunos[indiceAluno] = aluno;
                    indiceAluno++;
                    break;

                case "2":
                    foreach (Aluno a in alunos)
                    {
                        if (!string.IsNullOrEmpty(a.Nome))
                        {
                            Console.WriteLine($"ALUNO: {a.Nome} - NOTA: {a.Nota}");
                        }
                    }
                    break;

                case "3":

                    if (indiceAluno == 0)
                    {
                        throw new Exception("Nenhum aluno adicionado!");
                    }
                    decimal notaTotal = 0;
                    for (int i = 0; i < indiceAluno; i++)
                    {
                        notaTotal = notaTotal + alunos[i].Nota;
                    }

                    decimal  notaMedia = notaTotal / indiceAluno;
                    Conceito conceitoGeral;
                    if (notaMedia < 2)
                    {
                        conceitoGeral = Conceito.E;
                    }
                    else if (notaMedia < 4)
                    {
                        conceitoGeral = Conceito.D;
                    }
                    else if (notaMedia < 6)
                    {
                        conceitoGeral = Conceito.C;
                    }
                    else if (notaMedia < 8)
                    {
                        conceitoGeral = Conceito.B;
                    }
                    else
                    {
                        conceitoGeral = Conceito.A;
                    }


                    Console.WriteLine($"Média = {notaMedia} - Conceito = {conceitoGeral}");

                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }

                opcaoUsuario = ObterOpcaoUsuario();
            }
        }