Muhaiminur
2/12/2018 - 10:31 PM

Finding Large into Array

Write a program which reads 5 numbers into an array and prints the largest number. If the user enters 7, 13, 2, 10, 6 then your program should print 13.

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package BASICJAVA;

import java.util.Scanner;

/**
 *
 * @author ABIR
 */
public class Finding_large_into_array {
    public static void main(String[]args){
        Scanner abir =new Scanner(System.in);
        int[] number=new int[5];
        for (int i = 0; i < number.length; i++) {
            System.out.println("Enter your "+(i+1)+" number");
            number[i]=abir.nextInt();
        }
        int result=0;
        for (int i = 0; i < number.length; i++) {
            if (number[i]>result) {
                result=number[i];
            }
        }
        System.out.println("Highest Number is "+result);
    }
}