-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVinteum.java
More file actions
39 lines (31 loc) · 934 Bytes
/
Copy pathVinteum.java
File metadata and controls
39 lines (31 loc) · 934 Bytes
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
package TodosExecicios;
//21 - Implemente um programa que leia um array de numeros do usuario e
//encontre a média dos numeros e quantos estão acima da média.
import java.util.Scanner;
public class Vinteum {
public static void main (String []args) {
Scanner sc = new Scanner(System.in);
System.out.println("Informe o tamanho do Array: ");
int tamanho = sc.nextInt();
Integer [] numero = new Integer[tamanho];
int quantos = 0;
int cont = 0;
int acima = 0;
int soma = 0;
System.out.println("Informe os números do array: ");
for (int i = 0; i < tamanho; i++) {
numero[i] = sc.nextInt();
soma +=numero[i];
cont++;
}
double m = (double) soma/cont;
for (int y=0; y < tamanho; y++) {
if (numero[y] > m) {
numero[y] = acima;
quantos++;
}
}
System.out.println("Estão acima da média " + quantos + " números.");
System.out.println("A média dos numeros é: " + m);
}
}