-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdezoito.java
More file actions
32 lines (26 loc) · 1015 Bytes
/
dezoito.java
File metadata and controls
32 lines (26 loc) · 1015 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
import java.util.Scanner;
public class dezoito {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Digite a quantidade de números (N): ");
int N = scanner.nextInt();
if (N <= 0) {
System.out.println("A quantidade de números deve ser maior que zero.");
return;
}
int menor = Integer.MAX_VALUE;
int maior = Integer.MIN_VALUE;
int soma = 0;
for (int i = 0; i < N; i++) {
System.out.print("Digite o número " + (i + 1) + ": ");
int numero = scanner.nextInt();
soma += numero;
if (numero < menor) menor = numero;
if (numero > maior) maior = numero;
}
System.out.println("Menor valor: " + menor);
System.out.println("Maior valor: " + maior);
System.out.println("Soma dos valores: " + soma);
scanner.close();
}
}