3:50 pm - Sunday February 19, 9105

find volume Of Sphere

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044

/**
* @Author: Candid Java
* @Description: Program To Find The Volume Of Sphere
*/

public class Sphere {
public static void main(String[] args) {
float pi = 3.14f;
String s1 = args[0]; // Get The Radius As Input
int r = Integer.parseInt(s1); // Convert The Input Into Integer
int r_cube = r * r * r; // Find The Cube Of The Radius
double volume = (4 * pi * r_cube) / 3; // Find The Volume
System.out.println("Volume of Sphere is: " + volume);
}
}

Output:

java Sphere 2
Volume of Sphere is: 33.49333572387695

java Sphere 3
Volume of Sphere is: 113.04000854492188

java Sphere 4
Volume of Sphere is: 267.9466857910156

Filed in: Z-A All Java Codes

Comments are closed.