jam/AreaAndVolume

From ggc

Jump to: navigation, search

01 package jam;
02 
03 import wiki.Wiki;
04 /**
05  * All about my application here.
06  @author Jam Jenkins
07  */
08 public class AreaAndVolume
09 {
10   public static void main(String[] args)
11   {
12     double radius=5;
13     //computes and stores pi r-squared
14     double area=Math.PI*radius*radius;
15     //computes and stores 4/3 pi r-cubed - note floating point arithmetic!
16     double volume=4.0/3.0*Math.PI*Math.pow(radius, 3);
17     Wiki.out.println("The area of a circle of radius "+radius+" is "+area);
18     Wiki.out.println("The volume of a sphere of radius "+radius+" is "+volume);
19     area=Math.round(area);
20     volume=Math.round(volume);
21     Wiki.out.println("Rounded to the nearest number:");
22     Wiki.out.println("The area of a circle of radius "+radius+" is "+area);
23     Wiki.out.println("The volume of a sphere of radius "+radius+" is "+volume);
24   }
25 }


Download/View jam/AreaAndVolume.java





Views
Personal tools
Add to 
del.icio.usAdd to 
diggAdd to 
FacebookAdd to 
favoritesAdd to 
GoogleAdd to 
MySpaceAdd to 
PrintAdd to 
SlashdotAdd to 
StumbleUponAdd to 
Twitter