Java Programs

Please click on 1-2 Ads to keep this website's Study Material FREE and regularly Updated.

Program 2: Write a Java program to calculate the volume of the Sphere.

Sphere.java

import java.util.Scanner;

public class Sphere
{
	public static void main(String[] args)
	{
		//Declaring Variable		
		int radius;
		double Volume;
		double pie=3.14;

		Scanner s =new Scanner(System.in);
		System.out.println("Enter the radius of Sphere");
		radius=s.nextInt();

		Volume=(4.0/3.0)*pie*(radius*radius*radius);

		System.out.println("Volume: "+Volume);
	}
}



If you have any suggestion or found any error in the above program, then do let us know at [email protected] or just comment below.