Switch to full style
Java2 codes,problems ,discussions and solutions are here
Post a reply

compute area of the circle.

Thu Jul 14, 2011 1:00 pm

Code:
//compute area of the circle.
class area{
public static void main(String[] args)
{
double pi,a;
pi=3.1415;
for(int r=1;r<5;r++)
{
a=pi*r*r;
}
System.out.println("Area of the circle is"+a);
}
}




cmd shows an error saying "a" needs to be initialized.. how can i do that when "a" is the result??



Re: compute area of the circle.

Thu Jul 14, 2011 5:32 pm

Code:
double pi,a;


to
Code:
double pi=0.0d,a=0.0d;


Post a reply
  Related Posts  to : compute area of the circle.
 Calculate the area of a circle of given radius     -  
 Java- Copy text area into disabled text area     -  
 Drawing circle using circle equation directly , on mouse     -  
 Area clipping     -  
 play a sound when the user enters the area- audio feedback     -  
 compute binomial coefficients     -  
 loop to compute the tuition in ten years     -  
 compute number of files in directory     -  
 Program to compute commission using two methods     -  
 Compute FFT (Fourier Transform) in ITK for a 2d image     -