Total members 10261 | Gratitudes |It is currently Wed May 23, 2012 8:03 am Login / Join Codemiles


All times are UTC [ DST ]




Post new topic Reply to topic  Quick reply  [ 2 posts ] 
Author Question
 Question subject: compute area of the circle.
PostPosted: 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??


TOP
  
Reply with quote  
 Question subject: Re: compute area of the circle.
PostPosted: Thu Jul 14, 2011 5:32 pm 
Offline
Mastermind
User avatar

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 )


TOP
 Profile Send private message  
Reply with quote  
Post new topic Reply to topic Quick reply  [ 2 posts ] 
Quick reply


  

 Similar topics
 rotate sphere in a circle with light
 Java- Copy text area into disabled text area
 compute binomial coefficients
 ellipse, circle, rectangle, square, or parallelogram
 i want to draw a circle on a image(any format bmp,jpeg etc.)
 Area clipping
 Calculate the area of a circle of given radius
 php drawing a circle with imagearc()
 php drawing a circle
 Drawing Circle using Mid-point implmented using J2me

All times are UTC [ DST ]


Users browsing similar posts

Users browsing this forum: No registered users and 2 guests



Jump to:  
Previous Question | Next Question 




Home
General Talks
Finished Projects
Code Library
Games
Tutorials

Java
C/C++
C-sharp
php
Script
JSP/Servlets
Ajax
ASP/ASP.net
Google SEO
Database
Communications
Phpbb3 styles
Photoshop tutorials
Flash tutorials
Find a job






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team