Home >Java >javaTutorial >Find angles centered on similar chords in Java
A circle is a circular two-dimensional figure without corners. Every circle has an origin, and every point on the circle is equidistant from the origin. The distance between the origin and a point in the circle is called the radius of the circle. Likewise, if we draw a line from one side of a circle to the other and the origin is in the middle of the line, then the line is called the diameter of the circle. Basically, the diameter is twice the length of the radius.
The chord of a circle refers to the line connecting one endpoint of the circle to the other endpoint of the circle. Or simply put, a chord is a line whose endpoints lie on a circle. The chord divides the circle into two parts.
According to the problem statement, we must find the length of the chord when given the radius of the circle and the angle subtended by the chord at the center.
The logic of finding the string length -
Angle subtended by the chord at centre = Angle subtended by another chord of same length at centre
So, let’s explore.
Assume the angle subtended by the center chord = 60
Therefore, the angle subtended by another string of the same length at the center = 60
Assume the angle subtended by the center chord = 45
Therefore, the angle subtended by another string of the same length at the center = 45
Assume the angle subtended by the center chord = 52
Therefore, the angle subtended by another string of the same length at the center = 52
Step 1 - Get the center angle subtended by the string via static input or user input.
Step 2 - Use the logic above to find the central angle subtended by another string of the same length.
Step 3 - Print the results.
We provide solutions in different ways.
By using static input values
By using user-defined methods
By using user input value
Let’s look at the program and its output one by one.
In this method, we initialize the angle subtended by the string in the program. Then through algorithm we can find the angle subtended by the other string.
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"); } }
Angle subtended at the center by the chord: 52 degrees
In this method, we accept the user input of the angle subtended by the string. Then calling the user defined method by passing this value as parameter and using algorithm inside the method we can find the angle subtended by the other string.
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"); } }
Angle subtended at the centre by the chord: 40 degrees
In this method, we accept the angle subtended by the string as input by the user in the program. Then through algorithm we can find the angle subtended by the other string.
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"); } }
Enter the angle subtended at center by the chord: 55 Angle subtended at the center by the chord: 55 degrees
In this article, we looked at how to find the angle subtended by one string given the angle subtended by another string of the same length using different methods in Java.
The above is the detailed content of Find angles centered on similar chords in Java. For more information, please follow other related articles on the PHP Chinese website!