Ask a Teacher



what is the program used to find the tempuature in java(bluej)


import java.io.*;
class Arr
{
int temp [][]=new int[5][4];
int i, j;
BufferedReader br=new BufferedReader(new InputStreamReader(Systm.in));
int maxc,minc,maxd,mind,maxt,mint,i,j;
public void take() throws IOException
{

for(i=0;i<5;i++)
{
for(j=0;j<4;j++)
{
if(j==0)
System.out.println ("Enter temp. of Calcutta on “ + (i+1) + “ January:”);
else if(j==1)
System.out.println ("Enter temp. of Chennai on “ + (i+1) + “ January:”);
else if(j==2)
System.out.println ("Enter temp. of Mumbai on “ + (i+1) + “ January:”);

else if(j==3)
System.out.println ("Enter temp. for Delhi on “ + (i+1) + “ January:”);
temp [i][j]=Integer.parseInt(br.readLine());

}
}
System.out.println ("The recorded temperature:-");
System.out.println ("Calcutta Madras Mumbai Delhi");
for(i=0;i<5;i++)
{
for(j=0;j<4;j++)
{
System.out.println (" ",temp[i][j]);
}
System.out.println ();
}
System.out.println ("**************");
for(i=0;i<5;i++)
{
for(j=0;j<4;j++)
{
if((i==0)&&(j==0))
{
maxt=temp[i][j];
maxd=i;
maxc=j;
mint=temp[i][j];
mind=i;
minc=j;
}
else
{
if(maxt
{
maxt=temp[i][j];
maxd=i+1;
maxc=j+1;
}
if(mint>temp[i][j])
{
mint=temp[i][j];
mind=i+1;
minc=j+1;
}
}
}
}
System.out.println ("The maximum temperature is :" + maxt);
System.out.println ("And the corresponding date is :"+ maxd);
System.out.println ("City number: "+ maxc);
System.out.println ("The minimum temperature is :" + mint);
System.out.println ("And the corresponding date is: " + mind);
System.out.println ("City number: " +minc);
}
}


comments powered by Disqus