AnandaVieira

Exercicio 55

May 11th, 2021 (edited)
892
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.56 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ScriptSCharp
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.  
  10.             /*Exercício 55
  11.              Um professor deseja um algoritmo pelo qual possa escolher que tipo de média
  12.             deseja calcular a partir de três notas.
  13.              Faça um algoritmo que leia as notas, a opção escolhida pelo usuário e calcule a
  14.             média:
  15.              1- aritmética
  16.              2- ponderada (pesos 3, 3, 4)*/
  17.  
  18.             Console.Write("Digite a 1ª nota: ");
  19.             double nota1 = double.Parse(Console.ReadLine());
  20.  
  21.             Console.Write("Digite a 2ª nota: ");
  22.             double nota2 = double.Parse(Console.ReadLine());
  23.  
  24.             Console.Write("Digite a 3ª nota: ");
  25.             double nota3 = double.Parse(Console.ReadLine());
  26.  
  27.             double arit = (nota1 + nota2 + nota3) / 10;
  28.             double pond = (nota1 * 3 + nota2 * 3 + nota3 * 4) / 10;
  29.  
  30.             Console.WriteLine("\nDigite a opção:\n1 - Aritmética\n2 - Ponderada");
  31.             int op = int.Parse(Console.ReadLine());
  32.  
  33.             switch (op)
  34.             {
  35.                 case 1:
  36.                     Console.WriteLine("A média Aritmética das 3 notas é: " + arit);
  37.                     break;
  38.                 case 2:
  39.                     Console.WriteLine("A média Aritmética das 3 notas é: " + pond);
  40.                     break;
  41.                 default:
  42.                     Console.WriteLine("Opção NÃO encontrada!");
  43.                     break;
  44.             }
  45.  
  46.         }
  47.  
  48.     }
  49.  
  50. }
Advertisement
Add Comment
Please, Sign In to add comment