Java Program to Find Area of a Circumscribed Circle of a Square

In the previous article, we have seen Java Program to Check if a Given Circle Lies Completely Inside the Ring Formed by Two Concentric Circle

In this article we will discuss about how to Find Area of a Circumscribed Circle of a Square using Java programming language.

Java Program to Find Area of a Circumscribed Circle of a Square

Before jumping into the program directly, let’s first know how we can Find Area of a Circumscribed Circle of a Square.

Explanation:

Formula to Find Area of a Circumscribed Circle of a Square: (pi*side*side)/2

Example:

When side=2

Area = (pi*side*side)/2

= (3.14*2*2)/2

= 6.28

Let’s see different ways to Find Area of a Circumscribed Circle of a Square.

Method-1: Java Program to Find Area of a Circumscribed Circle of a Square By Using Static Value

Approach:

  • Declare the value for side of the square.
  • Use the formula (pi*side*side)/2 to calculate the area.
  • Then print the result.

Program:

import java.util.Scanner;
public class Main
{
    public static void main(String[] args)
    {
        // Static initialization of side of the square
        double pi = 3.14;
        double side = 60;
        // Prints result of the square
        System.out.println("Area of the square "+(pi*side*side/2));
    }
}
Output:

Area of the square 5652.0

Method-2: Java Program to Find Area of a Circumscribed Circle of a Square By User Input Value

Approach:

  • Take user input the value side of the square.
  • Use the formula (pi*side*side)/2 to calculate the area.
  • Then print the result.

Program:

import java.awt.Point; 
import java.util.Scanner;
import static java.lang.Math.*;

public class Main
{
    public static void main(String[] args)
    {
        Scanner scan = new Scanner(System.in);
        // Asking the user to input the side of the square
        System.out.println("Enter the side of the square");
        double pi = 3.14;
        double side = scan.nextInt();
        // Prints result of the square
        System.out.println("Area of the square "+(pi*side*side/2));
    }
}
Output:

Enter the side of the square
6
Area of the square 56.519999999999996

Provided list of Simple Java Programs is specially designed for freshers and beginners to get familiarize with the concepts of Java programming language and become pro in coding.

Related Java Articles: