Java Program to Find Surface Area of Hemisphere

In the previous article, we have seen Java Program to Find Volume of Hemisphere

In this article we are going to see how to find the surface area of hemisphere using Java programming language.

Java Program to Find Surface Area of Hemisphere

Before Jumping into the program directly let’s see how we can find the surface area of hemisphere.

Explanation:

 Formula to find total surface area of hemisphere = 3 * pie * (radius of hemisphere)^2

Example:

Let radius of hemisphere be “r” = 1 & Pie = 3.14

So, vol. of hemisphere = 3 * pie* r^2

=> 3 * 3.14 * (1^2) = 9.42

Let’s see different ways to find surface area of hemisphere.

Method-1: Java Program to Find Surface Area of Hemisphere By Using Static Value

Approach:

  • Declare an double variable say ‘r’ and assign the value to it, which holds the radius value of hemisphere.
  • Declare the value of pie i.e 3.14
  • Find the surface area of hemisphere using the formula 3 * pie *(r^2)
  • Print the result.

Program:

class Main
{
    public static void main(String [] args)
    {
        //radius of hemisphere is declared
        int r = 1;
        //pie value declared
        double pie = 3.14;
        //find suraface area using formula
        double surface =  3 * pie * r * r;
        System.out.println("The surface area of hemisphere is : " + surface);
    }
}
Output:

The surface area of hemisphere is : 9.42

Method-2: Java Program to Find Surface Area of Hemisphere By Using User Input Value

Approach:

  • Declare a double variable say ‘r’ and take the value of it as user input, which holds the radius value of hemisphere.
  • Declare the value of pie i.e 3.14
  • Find the surface area of hemisphere using the formula 3 * pie *(r^2)
  • Print the result.

Program:

import java.util.*;

class Main
{
    public static void main(String [] args)
    {
        Scanner sc = new Scanner(System.in);
        //Taking input of radius value of hemisphere
        System.out.println("Enter the value of radius of the hemisphere:");
        double r = sc.nextInt();
        //pie value declared
        double pie = 3.14;
        //find suraface area using formula
        double surface =  3 * pie *(r * r);
        System.out.println("The surface area of hemisphere is : " + surface);
    }
}
Output:

Enter the value of radius of the hemisphere:
2
The surface area of hemisphere is : 37.68

Method-3: Java Program to Find Surface Area of Hemisphere By Using User Input Value

Approach:

  • Declare a double variable say ‘r’ and take the value of it as user input, which holds the radius value of hemisphere.
  • Call the user defined  method surafaceArea() by passing the ‘r‘ value as parameter.
  • Inside method, declare the value of pie i.e 3.14
  • Find the surface area of hemisphere using the formula 3 * pie *(r^2)
  • Print the result.

Program:

import java.util.*;

class Main
{
    public static void main(String [] args)
    {
        Scanner sc = new Scanner(System.in);
        //Taking input of radius value of hemisphere
        System.out.println("Enter the value of radius of the hemisphere:");
        double r = sc.nextInt();
        //calling the user defined method surfaceArea()
        surfaceArea(r);
    }
    
    public static void surfaceArea(double radius)
    {
        //pie value declared
        double pie = 3.14;
        //find suraface area using formula
        double surface =  3 * pie *(radius * radius);
        System.out.println("The surface area of hemisphere is : " + surface);
    }
}
Output:

Enter the value of radius of the hemisphere:
2
The surface area of hemisphere is : 37.68

Beginners and experienced programmers can rely on these Best Java Programs Examples and code various basic and complex logics in the Java programming language with ease.

Related Java Articles: