-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNove.java
More file actions
31 lines (23 loc) · 744 Bytes
/
Copy pathNove.java
File metadata and controls
31 lines (23 loc) · 744 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;
//9.Façaumprogramaqueleiaumarraydenúmerosdousuárioatéqueousuárioinsira0.
//Emseguida,imprimaaquantidadedenúmeroslidos.
import java.util.Scanner;
public class Oitavo {
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 cont = 0;
System.out.println("Informe os números do array: ");
System.out.println("Ou digite 0 para encerrar. ");
for (int i = 0; i < tamanho; i++) {
numero[i] = sc.nextInt();
if (numero [i] == 0) {
break;
}
cont++;
}
System.out.println("Foram informados " + cont + " números.");
}
}