# Java Program to calculate Surface Area and Volume of Sphere

Welcome to the new tutorial Java Program to calculate Surface Area and Volume of Sphere of the Java Geometrical Calculation Programs series. In this post, we will learn to calculate the surface area and volume of the sphere in Java.

The previous tutorial of this series is Java Program to calculate volume of cone. Now here we will write a program to find the area and volume of the sphere in Java.

We can calculate the surface area and volume of the sphere using the following mathematical formula.formula.

Surface area of sphere, A = 4 π r2

Where,

• π is a constant whose value is 3.1415 or 22/7
• r is the radius of the sphere.

Volume of sphere, V = (4 ⁄ 3) π r3

Where,

• π is a constant whose value is 3.1415 or 22/7
• r is the radius of the sphere.

Now let’s write the program.

## Java Program to calculate Surface Area and Volume of Sphere

### What we did ?

• First of all we have imported the util package.
• Then created a class and named it Sphere.
• After that started main() method of the program.
• Then inside main() method declared variables.
• Then created object of the Scanner class.
• Now asked the user to enter the radius of the sphere. Then read the value of radius of the sphere entered by the user.
• Then calculated surface area of the sphere using the formula area = 4 * Math.PI * r * r.
• After that calculated volume of the sphere using the formula volume = (4 * Math.PI * r * r)/3.
• Then finally displayed the value of the surface area and the volume of the sphere on the screen.

Now let’s check the output of the above code.

Output

The Java program to calculate surface area and volume of sphere has been successfully completed. In the next tutorial, we will learn Java Program to calculate Total Surface Area and Curved Surface Area of cylinder.

Related Tutorials…