Java Program to Find Length of the Chord the circle if Length of Another Chord Which is Equally Inclined through the Diameter is Given

In the previous article, we have discussed about Java Program to Find Distance between Centers of Two Intersecting Circles if the Radius and Common Chord Length is Given

In this article we are going to see how to find length of the chord the circle if length of another chord which is equally inclined through the diameter is given by using Java programming language.

Java Program to Find Length of the Chord the circle if Length of Another Chord Which is Equally Inclined through the Diameter is Given

Suppose there is a circle with center O

Let, 2 chords are equally inclined through the diameter of the circle PQ, PR

Length of one chord is given. (Say PQ)

Now we need to find the length of another chord.

OL is perpendicular to PQ

OM is perpendicular to PR

Java Program to Find Length of the Chord the circle if Length of Another Chord Which is Equally Inclined through the Diameter is Given

In triangles OLP & OMP,
angle OLP = angle OMP  (90 degrees)
angle OPL = angle OPM (chords equally inclined)
OP = OP (common side)

So triangle OLP and triangle OMP are congruent to each other.

So, OL = OM

and we know, equal chords are equidistant from the center.

So Length of PQ and PR will be same.

Example:

PQ and PR 
If length of chord PQ = 12.45
Then length of chord PR = 12.45

Let’s see different ways to find length of the chord the circle if length of another chord which is equally inclined through the diameter is given.

Method-1: Java Program to Find Length of the Chord the circle if Length of Another Chord Which is Equally Inclined through the Diameter is Given By Using Static Input Value

Approach:

  • Declare an double variable say ‘PQ’ and assign the value to it, which holds the length of the chord PQ.
  • Find the length of another chord PR which is same as the length of chord PQ
  • Print the result.

Program:

import java.io.*;
class Main
{
 public static void main(String [] args)
 {
  double PQ = 12.45;
  // formula to find the length of chord PR
  double PR = PQ;
  System.out.println(“The length of the chord PR is ” + PR);
 }
}
Output:

The length of the chord PR is 12.45

Method-2: Java Program to Find Length of the Chord the circle if Length of Another Chord Which is Equally Inclined through the Diameter is Given By Using User Input Value

Approach:

  • Declare an double variable say ‘PQ’ which holds the length of the chord PQ.
  • Then we will take the value of “PQ” as user input using scanner class.
  • Find the length of another chord PR which is same as the length of chord PQ
  • Print the result.

Program:

import java.io.*;
import java.util.Scanner;
class Main
{
 public static void main(String [] args)
 {
  Scanner s = new Scanner(System.in);   // scanner class obj ref 
  System.out.println(“Enter the    radius length of the chord PQ”);
  double PQ = s.nextDouble();                                        // to take user input value
  // formula to find the length of chord PR
  double PR = PQ;
  System.out.println(“The length of the chord PR is ” + PR);
 }
}

Output:

Enter the radius length of the chord PQ
21.69
The length of the chord PR is 21.69

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 Programs: