-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQuinze.java
More file actions
38 lines (28 loc) · 846 Bytes
/
Copy pathQuinze.java
File metadata and controls
38 lines (28 loc) · 846 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
package TodosExecicios;
//15.Crieumprogramaqueleiaumarraydenúmerosdousuário
//atéqueousuárioinsiraumnúmeroquesejamaiorqueoanterior.
import java.util.ArrayList;
import java.util.Scanner;
public class Quatorze {
public static void main (String []args) {
ArrayList<Integer> maiores = new ArrayList<>();
Scanner sc = new Scanner(System.in);
int guardar = 0;
int cont = 0;
while(true) {
System.out.println("Digite um número maior que o informado anteriormente para encerrar. ");
System.out.println("Informe números: ");
Integer maior = sc.nextInt();
maiores.add(maior);
if (guardar == 0){
guardar = maior;
} else if (guardar < maiores.get(cont)) {
break;
}
guardar = maiores.get(cont);
cont++;
}
System.out.println("Foram informados " + cont + " números.");
sc.close();
}
}