Created
March 28, 2017 21:43
-
-
Save coke1337/63868727c15c86b7b244375574bbb724 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; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace ConsoleApplication3 | |
{ | |
class Adega_de_Vinhos | |
{ | |
static void Main(string[] args) | |
{ | |
Console.WriteLine("Bem vindo a Adega mais dificil de programar de todos os tempos! \nObs: Foi dificil mesmo!"); | |
Console.WriteLine("Digite [T] para Tinto, [B] para Branco, [R] para Rose, ou [F] para Finalizar: "); | |
double cv = 0, ct = 0, cb = 0, cr = 0; | |
string tecla; | |
string[] teclasPermitidas = { "T", "B", "R", "F" }; | |
do | |
{ | |
tecla = Console.ReadLine().ToUpper(); | |
if (Array.IndexOf(teclasPermitidas, tecla) == -1) | |
{ | |
Console.WriteLine("Operação Invalida!"); | |
Console.WriteLine("Favor Digitar [T] para Tinto, [B] para Branco, [R] para Rose, ou [F] para Finalizar!"); | |
Console.WriteLine("Numero de Tintos ja digitados: " + ct + "\nNumero de Brancos ja digitados: " + cb + "\nNumero de Roses ja digitados: " + cr + "\nTotal de Vinhos: " + cv); | |
continue; | |
} | |
switch (tecla) | |
{ | |
case "T": | |
cv++; ct++; | |
break; | |
case "B": | |
cv++; cb++; | |
break; | |
case "R": | |
cv++; cr++; | |
break; | |
} | |
} while (tecla != "F"); | |
Console.WriteLine("Numero de vinhos Tinto: " + ct + " \nNumero de vinhos Branco: " + cb + " \nNumero de vinhos Rose: " + cr + "\nTotal de vinhos: " + cv); | |
Console.WriteLine("Porcentagem de vinhos Tintos: "+ (cv > 0 ? ct * 100 / cv : 0)); | |
Console.WriteLine("Porcentagem de vinhos Brancos: " + (cv > 0 ? cb * 100 / cv : 0)); | |
Console.WriteLine("Porcentagem de vinhos Roses: " + (cv > 0 ? cr * 100 / cv : 0)); | |
Console.ReadKey(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment