From ggc
|
01 packagepackage is used to name the directory or folder a class is in jam;
02
03 importimport means to make the classes and/or packages available in this program wiki.Wiki;
04 /**
05 * All about my application here.
06 * @authorthis is the Javadoc tag for documenting who created the source code Jam Jenkins
07 */
08 publicpublic is used to indicate unrestricted access (any other class can have access) classclass is a group of fields and methods used for making objects AreaAndVolume
09 {open braces start code blocks and must be matched with a close brace
10 publicpublic is used to indicate unrestricted access (any other class can have access) staticstatic means that an instance is not required for access (class level access) voidvoid means the method does not return a value mainThe main method is the place where applications begin executing.(String[brackets are typically used to declare, initialize and index (indicate which element of) arrays]brackets are typically used to declare, initialize and index (indicate which element of) arrays args)
11 {open braces start code blocks and must be matched with a close brace
12 doubledouble is the type for numbers that can contain decimal fractions radius=this assignment operator makes the left side equal to the right side5;
13 //computes and stores pi r-squared
14 doubledouble is the type for numbers that can contain decimal fractions area=this assignment operator makes the left side equal to the right sideMath.PI*radius*radius;
15 //computes and stores 4/3 pi r-cubed - note floating point arithmetic!
16 doubledouble is the type for numbers that can contain decimal fractions volume=this assignment operator makes the left side equal to the right side4.0/3.0*Math.PI*Math.pow(radius, 3);
17 Wiki.out.println("The area of a circle of radius "+adds two numbers together or concatenates Strings togetherradius+adds two numbers together or concatenates Strings together" is "+adds two numbers together or concatenates Strings togetherarea);
18 Wiki.out.println("The volume of a sphere of radius "+adds two numbers together or concatenates Strings togetherradius+adds two numbers together or concatenates Strings together" is "+adds two numbers together or concatenates Strings togethervolume);
19 area=this assignment operator makes the left side equal to the right sideMath.round(area);
20 volume=this assignment operator makes the left side equal to the right sideMath.round(volume);
21 Wiki.out.println("Rounded to the nearest number:");
22 Wiki.out.println("The area of a circle of radius "+adds two numbers together or concatenates Strings togetherradius+adds two numbers together or concatenates Strings together" is "+adds two numbers together or concatenates Strings togetherarea);
23 Wiki.out.println("The volume of a sphere of radius "+adds two numbers together or concatenates Strings togetherradius+adds two numbers together or concatenates Strings together" is "+adds two numbers together or concatenates Strings togethervolume);
24 }close braces end code blocks and must match an earlier open brace
25 }close braces end code blocks and must match an earlier open brace
|
Download/View jam/AreaAndVolume.java