Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package exercicios;
- import java.util.Scanner;
- public class ex20 {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- int numero;
- int maior = 0;
- int menor = 0;
- int total = 5;
- for(int i = 0;i<total;i++){
- System.out.println("Digite o valor: ");
- numero = sc.nextInt();
- if(i == 0){
- maior = numero;
- menor = numero;
- }
- if(numero > maior){
- maior = numero;
- }
- if(numero < menor){
- menor = numero;
- }
- }
- System.out.println("O maior número digitado é: "+maior);
- System.out.println("O menor número digitado é: "+menor);
- }
- }
- /* César N. */
- //Receber X números e mostrar o maior e menor número digitado.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement