7. JAVA Program to find Area of a Sphere.
How does this program work?
- In this programme you will learn about how to calculate Area a Sphere.
- This programme requires the user input to enter the Radius of a Sphere.
- This programme perform mathematical calculation and display the result using java.
Here is the code
// Area of a Sphere
import java.util.Scanner;public class Sphere
{
public static void main(String args[])
{
int r;
double area;
System.out.println("Enter Radius:\n");
Scanner obj=new Scanner(System.in);
r=obj.nextInt();
area=4*3.14*r*r;
//Formula for area of sphere
System.out.println("Area of the sphere is: "+area );}
}