-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDezenove.java
More file actions
31 lines (25 loc) · 849 Bytes
/
Copy pathDezenove.java
File metadata and controls
31 lines (25 loc) · 849 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
package TodosExecicios;
//19 - Crie um programa que leia um array de números do usuário e encontre o maior número
//e sua posição no array.
import java.util.Scanner;
public class Dezoito {
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 posicao = 0;
System.out.println("Informe os números: ");
for (int i = 0; i < tamanho; i++) {
numero[i] = sc.nextInt();
}
int maior = numero[0];
for (int y = 0; y < numero.length ; y++) {
if (numero[y]> maior) {
maior = numero[y];
posicao = y;
}
}
System.out.println("O maior numero informado é: " + maior + "\nSua posição é: " + posicao);
}
}