hercioneto

Exercício 1 - 2-10-18

Oct 2nd, 2018
372
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.10 KB | None | 0 0
  1. //Rextester.Program.Main is the entry point for your code. Don't change it.
  2. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5
  3.  
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text.RegularExpressions;
  8.  
  9. namespace Rextester
  10. {
  11.     public class Program
  12.     {
  13.         public static void Main(string[] args)
  14.         {
  15.            
  16.             string sexo = "";
  17.             double altura = 0;
  18.             double mediaG = 0;
  19.             double mediaH = 0;
  20.             double mediaF = 0;
  21.             double maiorAltura = 0;
  22.             double somaH = 0;
  23.             double somaF = 0;
  24.             double somaG = 0;
  25.             int totalPessoas, homens = 0;
  26.             totalPessoas = 4;
  27.             string aux;
  28.             for (int p = 0; p<totalPessoas; p++) {
  29.                 Console.WriteLine("Digite o sexo da pessoa {0}", (p+1));
  30.                 sexo = Console.ReadLine();
  31.                 Console.WriteLine("Digite a altura da pessoa {0} em cms ", (p+1));
  32.                 aux = Console.ReadLine();
  33.                 altura = Convert.ToDouble(aux);
  34.                 Console.WriteLine("Sexo e altura lidos {0} {1}", sexo, altura);
  35.                 somaG =somaG + altura;
  36.                 if (maiorAltura < altura) {
  37.                     maiorAltura = altura;
  38.                 }
  39.                 if (sexo == "M") {
  40.                     somaH = somaH + altura;
  41.                     homens++;
  42.                 }
  43.                 else {
  44.                     somaF = somaF + altura;
  45.                 }
  46.             }
  47.             mediaG = somaG/totalPessoas;
  48.             mediaH = somaH/homens;
  49.             mediaF = somaF/(totalPessoas-homens);
  50.             Console.WriteLine("A altura média das pessoas é: {0}", mediaG);
  51.             Console.WriteLine("A altura média dos homens é: {0}", mediaH);
  52.             Console.WriteLine("A altura média das mulheres é: {0}", mediaF);
  53.             Console.WriteLine("A maior altura é: {0}", maiorAltura);
  54.             Console.WriteLine("A quantidade de homens é: {0}", homens);
  55.            
  56.            
  57.         }
  58.     }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment