So i wanna print this code.. it says:
non - static method rain cannot be accessed from a static context.
the question is to print the names of all the months and their rainfall in parallel columns and their total average and the month with highest and lowest rainfall.
Please help me out.
public class rainfall
{
String[] rain = { "Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec" };
double[] values = { 0.40,0.94,3.21,3.74,1.73,1.03,1.27,2.58,6.98,6.90,2.80,2.53};
public double Total( double total )
{
total = 0;
for( int i = 0 ; i < values.length ; i ++ )
{
total += values[i];
}
return total;
}
public double Average( double average)
{
double total = 0;
Total (total);
for ( int j = 0; j < values.length; j ++ )
{
average = total/values.length ;
}
return average;
}
public String mostRain (double high,String highest )
{
high = values[0];
for(int i = 1 ; i < rain.length ; i ++ )
{
if ( values[i]>high )
{
highest = rain[i];
}
return highest;
}
}
public String leastRain ( String least, double low )
{
least = "";
low= values[0];
for(int i = 1; i < rain.length ; i++ )
{
if ( values[i]<low )
{
least = rain[i];
}
return least;
}
}
public static void main(String[]Args)
{
String highest = "" ;
String least = "";
double total = 0 ;
double average = 0 ;
double high = 0;
double low = 0;
System.out.println(" AUSTIN Tx RAINFALL 2009 " );
for( int i = 0 ; i < rain.length ; i ++ )
{
System.out.println(rain[i]+"\t"+values[i]);
}
System.out.println(Total(total));
System.out.println(Average(average));
System.out.println(mostRain(highest,high));
System.out.println(leastRain(least,low));
}
}