# Java Program to Find Arc Length from Given Angle

In the previous article, we have seen Java Program to Find Center of the Circle Using Endpoints of Diameter

In this article we are going to see how to find arc length from given angle using Java programming language.

## Java Program to Find Arc Length from Given Angle

Before Jumping into the program directly let’s see how we can find arc length from given angle.

Explanation:

Let us assume there is a circle with center C
From the center lets draw 2 rays intersecting the circle at A & B.

So the angle made between the 2 rays (AC & BC) i.e ACB is called angle of the circle.
Now, In a circle, the length of an arc is a portion of the circumference of the circle
and it is the distance between point A to point B of the circle within the angle(ACB).

Hence, the length of the arc = (pi * diameter) * (angle / 360)

Example:

Diameter of the circle “D” = 4
Angle = 45
Length of arc “L” = (pi * diameter) * (angle / 360) = (3.14*4)*(45/360) = 1.57
Where value of pi = 3.14
Note: Angle in degree should be <= 360

Let’s see different ways to find arc length from given angle.

### Method-1: Java Program to Find Arc Length from Given Angle By Using Static Value

Approach:

• Declare a double variable say ‘D’ and assign the value to it, which holds the value of diameter of the circle.
• Declare a double variable say ‘A’ and assign the value to it, which holds the value of angle of arc of the circle.
• Declare a double variable say ‘pi’ and assign the value to it, which holds the value 3.14.
• Declare a double variable say ‘L’ which will hold the value of arc length using the formula (pi*diameter)* (angle/360)
• Print the result.

Program:

import java.io.*;
class Main
{
public static void main(String [] args)
{
//diameter declared
double D = 4;
//angle of arc of circle declared
double A = 45;
//pie value declared
double pi = 3.14;
// formula to find arc length
double L = (pi * D) * (A / 360);
if(A > 360)
System.out.println("Not possible");
else
System.out.println("The arc length is:" + L);
}
}

Output:

The arc length is:1.57

### Method-2: Java Program to Find Arc Length from Given Angle By Using Static Value

Approach:

• Declare a double variable say ‘D’ which holds the value of diameter of the circle.
• Declare a double variable say ‘A’ which holds the value of angle of arc of the circle.
• Declare a double variable say ‘pi’ and assign the value to it, which holds the value 3.14.
• Take the user input of values of D and A
• Declare a double variable say ‘L’ which will hold the value of arc length using the formula (pi*diameter)* (angle/360)
• Print the result.

Program:

import java.util.*;
class Main
{
public static void main(String [] args)
{

Scanner s = new Scanner(System.in);
//taking input of diameter value
System.out.println("Enter the value of diameter of the circle: ");
double D = s.nextDouble();
//taking input of angle of arc of circle
System.out.println("Enter the value of arc angle: ");
double A = s.nextDouble();
//pie value declared
double pi = 3.14;

// formula to find arc length
double L = (pi * D) * (A / 360);

if(A > 360)
System.out.println("Not possible");
else
System.out.println("The arc length is: " + L);
}
}

Output:

Enter the value of diameter of the circle:
6
Enter the value of arc angle:
60
The arc length is: 3.1399999999999997

Are you wondering how to seek help from subject matter experts and learn the Java language? Go with these Basic Java Programming Examples and try to code all of them on your own then check with the exact code provided by expert programmers.

Related Java Articles: