Find Angle while Angle by similar Chord at center in Java


A circle is a round shape two-dimensional diagram that has no corners. Every circle has an origin point and every point on the circle maintains an equal distance from the origin. The distance between the origin and a point in a circle is known as the Radius of the circle. And similarly, if we draw a line from one edge to another edge of the circle and the origin is held in the middle of it, that line is known as the diameter of the circle. Basically, the diameter is double of the length of the radius.

The chord of the circle refers to a line touching from one endpoint of the circle to another endpoint of the circle. Or simply we can say a chord refers to the line whose endpoints lie on the circle. A chord divides the circle into two parts.

As per the problem statement, we have to find the length of the chord when the radius of the circle and angle subtended at the center by the chord is given.

Logic to find length of chord −

Angle subtended by the chord at centre = Angle subtended by another chord of same length at centre

So, let’s explore.

To Show You Some Instances

Instance-1

Let say angle subtended by the chord at centre = 60

So, the angle subtended by another chord of same length at centre = 60

Instance-2

Let say angle subtended by the chord at centre = 45

So, the angle subtended by another chord of same length at centre = 45

Instance-3

Let say angle subtended by the chord at centre = 52

So, the angle subtended by another chord of same length at centre = 52

Algorithm

  • Step 1 − Get the angle at the centre subtended by the chord either by static input or by user input.

  • Step 2 − Find the angle at the centre subtended by another chord of same length by using the above explained logic.

  • Step 3 − Print the result.

Multiple Approaches

We have provided the solution in different approaches.

  • By Using Static Input Value

  • By Using User-Defined Method

  • By Using User Input Value

Let’s see the program along with its output one by one.

Approach-1: By Using Static Input Value

Example

In this approach, we initialize the angle subtended by the chord in the program. Then by using the algorithm we can find angle subtended by another chord.

import java.io.*;
public class Main{

   //main code
   public static void main (String[] args){
   
      //angle subtended by chord
      int angle = 52;
      System.out.println("Angle subtended at the center by the chord: "+angle+" degrees");
   }
}

Output

Angle subtended at the center by the chord: 52 degrees

Approach-2: By Using User Defined Method

Example

In this approach, we take user input of the angle subtended by the chord. Then call a user defined method by passing this value as parameter and inside the method by using the algorithm we can find the angle subtended by another chord.

import java.io.*;
public class Main{

   //main code
   public static void main (String[] args){
   
      //angle subtended by chord
      int angle = 40;
      findAngle(angle);
   }
    
   //user defined method to find the angle subtended by another chord
   static void findAngle(int angle){
      System.out.println("Angle subtended at the centre by the chord: "+angle+" degrees");
   }
}

Output

Angle subtended at the centre by the chord: 40 degrees

Approach-3: By Using User Input Value

Example

In this approach, we take the user input of the angle subtended by the chord in the program. Then by using the algorithm we can find angle subtended by another chord.

import java.io.*;
import java.util.*; 
public class Main{

   //main code
   public static void main (String[] args){
   
      //Create object of Scanner class
      Scanner sc = new Scanner(System.in);
      
      //angle subtended by chord
      System.out.println("Enter the angle subtended at center by the chord:");
      int angle = sc.nextInt();
      System.out.println("Angle subtended at the center by the chord: "+angle+" degrees");
   }
}

Output

Enter the angle subtended at center by the chord:
55
Angle subtended at the center by the chord: 55 degrees

In this article, we explored how to find the angle subtended by a chord when the angle subtended by another chord of the same length is given by using different approaches in Java.

Updated on: 05-Jan-2023

78 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements