-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPrincipal.java
More file actions
29 lines (21 loc) · 968 Bytes
/
Copy pathPrincipal.java
File metadata and controls
29 lines (21 loc) · 968 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
package TodosExecicios;
import java.util.Scanner;
public class Principal {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
// Pergunta ao usuário o tamanho do array
System.out.print("Digite o tamanho do array: ");
int tamanhoArray = scanner.nextInt();
// Instancia um objeto da classe ArrayNumeroInteiro
ArrayNumeroInteiro arrayInteiro = new ArrayNumeroInteiro(tamanhoArray);
// Preenche o array com números fornecidos pelo usuário
for (int i = 0; i < tamanhoArray; i++) {
System.out.print("Digite o número " + (i + 1) + ": ");
int numero = scanner.nextInt();
arrayInteiro.adicionar(numero);
}
// Calcula a média e mostra o resultado
int media = arrayInteiro.calculaMedia();
System.out.println("A média dos números é: " + media);
}
}