package lord1;
import javax.swing.JOptionPane;
public class lwarray {
public static void main(String[]args)
{
double array [][] = new double [5][2];
int colum=5;
int rows=2;
double high=0;
double low=0;
int i,j = 0,z=0,loop1=0;
Integer f=0,location;
for ( i = 0; i <5; i++)
{
for ( j = 0; j <2; j++)
{
do{
loop1=0;
z=0;
String user=JOptionPane.showInputDialog(null,"Location"+ "["+ i + " ]" + " " + "["+ j + " ]" + "Enter number");
for(int x=0;x< user.length();x++)
{
char c = user.charAt(x);
int ascii = (int) c;
if((ascii>=48 && ascii<=57))
{
z=1;
}
else
{
loop1=1;
}
}
if(z==1 && loop1==0 )
{
f =Integer.parseInt(user);
array[i][j] = f;
}
else
{
JOptionPane.showMessageDialog(null,"Please try Again");
}
}
while(loop1>0 );
}
}
int in=0,jn=0,in1=0,jn1=0;
for ( i = 0; i <5; i++)
{
for ( j = 0; j <2; j++)
{
if(i==0 && j==0)
{
high=array[i][j];
low=array[i][j];
}
if( array[i][j] >= high)
{
high = array[i][j] ;
in1=i;
jn1=j;
}
if(array[i][j] <= low)
{
low = array[i][j];
in=i;
jn=j;
}
}
}
JOptionPane.showMessageDialog(null,"Location"+ "["+ in1 + " ]" + " " + "["+ jn1 + " ]" + "High is: " + high + "\n");
JOptionPane.showMessageDialog(null,"Location"+ "["+ in + " ]" + " " + "["+ jn + " ]" + "Low is:" + low);
}
}
No comments:
Post a Comment