Created
October 15, 2017 23:59
-
-
Save jean-lourenco/a1dbd94a9687b25b64735cd42d920ca6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace coisas | |
{ | |
public class Program | |
{ | |
public static void Main(string[] args) | |
{ | |
var total = 0; | |
var impares = 0; | |
var pares = 0; | |
var maiores100 = 0; | |
while (true) | |
{ | |
Console.WriteLine("Informe um número"); | |
if (!Int32.TryParse(Console.ReadLine(), out var valor)) | |
continue; | |
if (valor == 0) | |
break; | |
if (valor % 2 == 0) | |
pares++; | |
else | |
impares++; | |
if (valor > 100) | |
maiores100++; | |
total += valor; | |
} | |
Console.WriteLine($@" | |
Total de valores: {pares + impares} | |
Total de pares: {pares} | |
Total de ímpares: {impares} | |
Acima de 100: {maiores100} | |
Média dos valores: {total / Math.Max(pares + impares, 1)}; | |
"); | |
Console.ReadLine(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment