-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExercicio5While.cs
65 lines (49 loc) · 1.82 KB
/
Exercicio5While.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
using System;
namespace prog_estruturad
{
class Exercicio5While
{
static void Main(string[] args)
{
//Exercicio 5 while
int somasim, somanao,respostasim, soma1, soma2;
string sexo, resposta;
float homemnao;
respostasim = 0;
homemnao = 0;
somasim = 0;
somanao = 0;
soma1 = 0;
soma2 = 0;
Console.Write("Opinião sobre produto (S-SIM/N-NÃO): ");
resposta = Console.ReadLine();
while (resposta != "sair")
{
Console.Write("Gênero (F/M): ");
sexo = Console.ReadLine();
Console.WriteLine("_____________");
if(resposta == "s"){
somasim += 1;
}
if(resposta == "n"){
somanao += 1;
}
if(sexo == "f" && resposta == "s"){
soma1 = soma1 + 1;
respostasim = soma1;
}
if(sexo == "m" && resposta == "n"){
soma2 = soma2 + 1;
homemnao = (100*soma2)/soma2;
}
Console.Write("Opinião sobre produto (S-SIM/N-NÃO): ");
resposta = Console.ReadLine();
}
Console.WriteLine("Nº de pessoas que votaram sim:{0}", somasim);
Console.WriteLine("Nº de pessoas que votaram nao:{0}", somanao);
Console.WriteLine("Nº de mulheres que votaram sim:{0}", respostasim);
Console.WriteLine("Porcentagem de homens que votaram nao:{0}", homemnao);
// FIM
}
}
}