//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??
msi_333
Question subject: Re: compute area of the circle.
Posted: Thu Jul 14, 2011 5:32 pm
Joined: Tue Mar 27, 2007 10:55 pm Posts: 2279 Location: Earth Has thanked: 39 time Have thanks: 61 time
Code:
double pi,a;
to
Code:
double pi=0.0d,a=0.0d;
_________________ Currenlty programming with : java , html , php , and javascript . (OCJP-6 certified )