In Volume of a Sphere in Java Example , Math.PI is used because it denotes the value of pi i.e. 3.1414. Math.pow(r,3.0) is used for computing y3
Here is the Java Example for Volume of a Sphere
class VolumeSphere
{
public static void main (String args [ ] )
{
int r;
double m,v;
r=9;
m=Math.pow(r,3.0);
v= (double)4/3*Math.PI*m;
System.out.println("Volume of a Sphere is "+v);
}
}
Dinesh Thakur holds an B.C.A, MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular Computer Notes blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.
Related Articles
Basic Courses
Advance Courses