-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquestao10.java
More file actions
39 lines (33 loc) · 1.3 KB
/
Copy pathquestao10.java
File metadata and controls
39 lines (33 loc) · 1.3 KB
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
// QUESTÃO 10 JAVA
import java.util.Scanner;
public class questao10 {
public static void main(String[] args) {
int sexo, qtMulheres=0, qtHomens=0;
float altura, somaH=0, mediaHomens=0, maior=0, menor=0;
Scanner entrada = new Scanner(System.in);
for (int i=0; i<10; i++) {
System.out.print("Escolha o sexo da pessoa (1-Mulher, 2-Homem): ");
sexo = entrada.nextInt();
System.out.print("Digite a altura: ");
altura = entrada.nextFloat();
if (sexo == 1) {
qtMulheres++;
} else if (sexo == 2) {
qtHomens++;
somaH = somaH + altura;
} else {
System.out.println("Opção sexo inválido!");
}
if (altura > maior) {
maior = altura;
} else if (altura < menor){
menor = altura;
}
}
mediaHomens = somaH / qtHomens;
System.out.println("A maior altura do grupo é de " + maior + " m, e a menor é de " + menor + " m");
System.out.println("A média de altura dos homens é " + mediaHomens + " m");
System.out.println("O número de mulheres é " + qtMulheres);
entrada.close();
}
}