
圆是没有角的圆形二维图。每个圆都有一个原点,圆上的每个点到原点的距离都相等。原点与圆中一点之间的距离称为圆的半径。同样,如果我们从圆的一条边到另一条边画一条线,并且原点位于该线的中间,则该线称为圆的直径。基本上,直径是半径长度的两倍。
圆的弦是指从圆的一个端点到圆的另一个端点的连线。或者简单地说,弦是指端点位于圆上的线。弦将圆分成两部分。
根据问题陈述,当给定圆的半径和弦在中心所对的角度时,我们必须找到弦的长度。
求弦长的逻辑 -
立即学习“Java免费学习笔记(深入)”;
Angle subtended by the chord at centre = Angle subtended by another chord of same length at centre
那么,让我们来探索一下。
假设中心弦所对的角度 = 60
因此,中心处另一个相同长度的弦所对的角度 = 60
假设中心弦所对的角度 = 45
因此,中心处另一个相同长度的弦所对的角度 = 45
假设中心弦所对的角度 = 52
因此,中心处另一个相同长度的弦所对的角度 = 52
第 1 步 - 通过静态输入或用户输入获取弦所对的中心角度。
步骤 2 - 使用上述逻辑找到另一个相同长度弦所对的中心角度。
第 3 步 - 打印结果。
我们通过不同的方式提供了解决方案。
通过使用静态输入值
通过使用用户定义的方法
通过使用用户输入值
让我们一一看看该程序及其输出。
在这种方法中,我们在程序中初始化弦所对的角度。然后通过算法我们可以找到另一个弦所对的角度。
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
在这种方法中,我们接受用户输入的弦所对的角度。然后通过将此值作为参数传递来调用用户定义的方法,并在方法内部使用算法我们可以找到另一个弦所对的角度。
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
在这种方法中,我们在程序中接受用户输入的弦所对的角度。然后通过算法我们可以找到另一个弦所对的角度。
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
在本文中,我们探讨了如何在 Java 中使用不同的方法给出另一个相同长度的弦所对的角度时找到一个弦所对的角度。
以上就是在Java中找到以相似弦为中心的角度的详细内容,更多请关注php中文网其它相关文章!
java怎么学习?java怎么入门?java在哪学?java怎么学才快?不用担心,这里为大家提供了java速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号