圆的弦是指从圆的一个端点到圆的另一个端点的连线。或者简单地说,弦是指端点位于圆上的线。弦将圆分成两部分。
根据问题陈述,当给定圆的半径和弦在中心所对的角度时,我们必须找到弦的长度。
求弦长的逻辑 -
angle subtended by the chord at centre = angle subtended by another chord of same length at centre
那么,让我们来探索一下。
向您展示一些实例实例1假设中心弦所对的角度 = 60
因此,中心处另一个相同长度的弦所对的角度 = 60
实例2假设中心弦所对的角度 = 45
因此,中心处另一个相同长度的弦所对的角度 = 45
实例3假设中心弦所对的角度 = 52
因此,中心处另一个相同长度的弦所对的角度 = 52
算法第 1 步 - 通过静态输入或用户输入获取弦所对的中心角度。
步骤 2 - 使用上述逻辑找到另一个相同长度弦所对的中心角度。
第 3 步 - 打印结果。
多种方法我们通过不同的方式提供了解决方案。
通过使用静态输入值
通过使用用户定义的方法
通过使用用户输入值
让我们一一看看该程序及其输出。
方法 1:使用静态输入值示例在这种方法中,我们在程序中初始化弦所对的角度。然后通过算法我们可以找到另一个弦所对的角度。
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
方法 2:使用用户定义的方法示例在这种方法中,我们接受用户输入的弦所对的角度。然后通过将此值作为参数传递来调用用户定义的方法,并在方法内部使用算法我们可以找到另一个弦所对的角度。
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
方法 3:使用用户输入值示例在这种方法中,我们在程序中接受用户输入的弦所对的角度。然后通过算法我们可以找到另一个弦所对的角度。
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:55angle subtended at the center by the chord: 55 degrees
在本文中,我们探讨了如何在 java 中使用不同的方法给出另一个相同长度的弦所对的角度时找到一个弦所对的角度。
以上就是在java中找到以相似弦为中心的角度的详细内容。