# Java Program to Find Volume and Surface Area of Sphere

In the previous article we have discussed Java Program to Find Area and Circumference of Circle

## Program to Find Volume and Surface Area of Sphere

Before jumping into the program directly, let’s first know how can we get volume and surface area of sphere.

Where,

• 'pie' represents PI value i.e. 3.141
• 'radius' represents radius of sphere.

Example:

Example- To find Volume of Sphere

When radius of  sphere  = 1
=> area =  4.1887902047863905
Example- To find Surface Area of Sphere

When radius of sphere = 1
=> Surface Area = 12.566370614359172

Now, let’s see the program.

Practice Java programming from home without using any fancy software just by tapping on this Simple Java Programs for Beginners tutorial.

### Method-1: Java Program to Find Volume and Surface Area of Sphere By Using Static Values

In this, the radius value of the sphere  is already declared by the program.

Let’s see the program to know how it is actually implemented.

import java.util.*;

public class Main
{
public static void main(String[] args)
{

//finding surface area of sphere
//finding volume of sphere

System.out.println("Surface area of Sphere = "+surfaceArea);
System.out.println("Volume of Sphere = "+ volume);
}
}
Output:

Surface area of Sphere = 12.566370614359172
Volume of Sphere = 4.1887902047863905

### Method-2: Java Program to Find Volume and Surface Area of Sphere By Using User Input Values

In this, the radius value of the sphere will be taken as input from the user.

Let’s see the program to know how it is actually implemented.

import java.util.*;

public class Main
{
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);

System.out.print("Enter the radius of Sphere = ");

System.out.println("Surface area of Sphere = "+surfaceArea);
System.out.println("Volume of Sphere = "+ volume);
}
}
Output:

Enter the radius of Sphere = 1
Surface area of Sphere = 12.566370614359172
Volume of Sphere = 4.1887902047863905

### Method-3: Java Program to Find Volume and Surface Area of Sphere By Using User Defined Method

In this, the radius value of the sphere will be taken as input from the user. And that radius value will be passed as the parameter to the user defined method.

Let’s see the program to know how it is actually implemented.

import java.util.*;

public class Main
{
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
//calling the calulate() method
}
//user defined method i.e calculate() method
// to find surface area and volume of sphere
{
//finding surface area of sphere
//finding volume of sphere

System.out.println("Surface area of Sphere = "+surfaceArea);
System.out.println("Volume of Sphere = "+ volume);
}
}
Output:

Enter the radius of Sphere = 1
Surface area of Sphere = 12.566370614359172
Volume of Sphere = 4.1887902047863905

Are you a job seeker and trying to find simple java programs for Interview? This would be the right
choice for you, just tap on the link and start preparing the java programs covered to crack the
interview.

Related Java Programs: