Nesta aula estudaremos os Operadores Relacionais, qual a representação pela linguagem C#, e estudaremos diversas situações onde é necessário a verificação de alguma relação entre 2 operados.

OPERADORES RELACIONAIS - EXEMPLO PRÁTICO

Está aula é uma continuação a respeito do estudo dos Operadores Relacionais já estudado!

EXEMPLO FEITO EM AULA

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

namespace Aula
{
    class Program
    {
        static void Main(string[] args)
        {
            //=========== eXcript.com ===========
            //======== NetCoders.com.br  ========

            double nota1, nota2, nota3, nota4 = 0;
            string frase = "Digite a {0}º nota: ";

            Console.WriteLine(frase, 1);
            nota1 = Convert.ToDouble( Console.ReadLine() );

            Console.WriteLine(frase, 2);
            nota2 = Convert.ToDouble( Console.ReadLine() );

            Console.WriteLine(frase, 3);
            nota3 = Convert.ToDouble(Console.ReadLine());

            Console.WriteLine(frase, 4);
            nota4 = Convert.ToDouble(Console.ReadLine());

            double total, media = 0;
            total = nota1 + nota2 + nota3 + nota4;
            media = total / 4;

            Console.WriteLine("A média foi: " + media);

            //Menor do que 4 - reprovado
            //Menor do que 7 - exame
            //aprovado

            if(media < 4)
            {
                Console.WriteLine("O aluno está reprovado.");
            }
            else
            {
                if(media < 7)
                {
                    Console.WriteLine("O aluno está em exame.");
                }
                else
                {
                    Console.WriteLine("O aluno foi aprovado");
                }
            }
        }
    }
}


Tags curso, csharp

Comentários

comments powered by Disqus