You are on page 1of 1

/*

* 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 array;

/**
*
* @author student
*/
import java.io.*;
public class Max_Min {

int no,a[],i;
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

void readData() throws Exception


{
System.out.println("enter size of array:");
no = Integer.parseInt(br.readLine());

System.out.println("Enter array elemenys:");


for(i=0;i<no;i++)
{
a[i] = Integer.parseInt(br.readLine());
}

void Maximum_Minimum() throws Exception


{
int max = a[0], min=a[0];

for(i=0;i<no;i++)
{
if(a[i]>max)
max = a[i];
if(a[i]<min)
min = a[i];
}

System.out.println("Maximum Element is : "+max);


System.out.println("Minimum Element is : "+min);
}

public static void main(String args[]) throws Exception{

Max_Min m = new Max_Min();

m.readData();
m.Maximum_Minimum();
}
}

You might also like