Advertisement
urksiful

Class 05 Practice 02

Oct 4th, 2016
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.82 KB | None | 0 0
  1.  
  2. import java.util.Scanner;
  3.  
  4. /*
  5.  * To change this license header, choose License Headers in Project Properties.
  6.  * To change this template file, choose Tools | Templates
  7.  * and open the template in the editor.
  8.  */
  9.  
  10. /**
  11.  *
  12.  * @author Hantack
  13.  */
  14. public class Practica02 {
  15.    
  16.     public static void main(String[] args) {
  17.         Scanner obj = new Scanner(System.in);
  18.         int array[] = new int[5];
  19.        
  20.         for (int i = 0; i < 5; i++) {
  21.             System.out.println("Ingresa número "+i);
  22.             array[i] = obj.nextInt();
  23.         }
  24.        
  25.         int mayor = array[0];
  26.         for (int i = 1; i < 5; i++) {
  27.             if(array[i]>mayor){
  28.                 mayor = array[i];
  29.             }
  30.         }
  31.        
  32.         System.out.println("El número mayor es el "+mayor);
  33.        
  34.     }
  35.    
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement