您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

使用给定的弧的宽度和高度计算圆的半径的JAVA程序

2024/5/14 17:28:58发布39次查看
一个圆是一个没有角的圆形二维图形。每个圆都有一个起点,圆上的每个点与起点保持相等的距离。起点和圆上一点之间的距离被称为圆的半径。类似地,如果我们从圆的一边到另一边画一条线,并且起点位于中间,那条线被称为圆的直径。基本上,直径是半径长度的两倍。
圆弧是指圆的一部分或一段周长。简单来说,它是圆周上的一个开放曲线。
根据问题陈述,我们需要找到当弧的宽度和高度给定时的圆的半径。
用给定的弧宽和弧高来计算圆的半径的公式为 −
$$mathrm{r=w^{2}/8h+h/2}$$
其中,'r'是一个圆的半径。
‘h’ 是弧的高度,‘w’ 是弧的宽度。
所以,让我们继续看看如何使用java编程语言来找到具有给定弧宽和弧高的圆的半径。
展示一些实例给你看− instance-1的中文翻译为:实例-1 let say height (h) of arc = 2. and width of (w) of arc = 4 radius of circle by using given width and height of arc = 2
instance-2的中文翻译为:实例-2 let say height (h) of arc = 3. and width of (w) of arc = 5 radius of circle by using given width and height of arc = 2.54
instance-3的中文翻译为:实例-3 let say height (h) of arc = 1. and width of (w) of arc = 4. radius of circle by using given width and height of arc = 2.5.
语法 要在java中获得一个数的任意次幂,我们可以使用内置的 java.lang.math.pow() 方法。
以下是使用方法获取2的幂的语法 -
double power = math.pow (inputvalue,2)
算法 步骤-1 − 通过静态输入或用户输入获取弧的宽度和高度。
步骤-2 − 通过使用公式找到圆的半径。
第三步 - 打印结果。
多种方法 我们以不同的方法提供了解决方案。
通过使用静态输入值。
通过使用用户定义的方法。
让我们逐个查看程序及其输出。
方法一:通过使用静态输入值 在这种方法中,我们声明两个双精度变量来保存弧的宽度和高度值,并在程序中初始化这些值。然后通过使用算法,我们可以找到圆的半径。
example的中文翻译为:示例 public class main { //main method public static void main(string[] args) { //width (w) and height (h) of arc double w = 5, h = 3; //find radius using the formula double r = ((w * w) / (8 * h) + h / 2); system.out.println( radius of the circle: +r); } }
输出 radius of the circle: 2.541666666666667
方法二:使用带有静态输入值的用户定义方法。 在这种方法中,我们声明两个双精度变量来保存弧的宽度和高度值,并将这些值作为用户输入。然后通过将这些值作为参数传递来调用一个用户定义的方法。然后在方法内部,通过使用算法,我们可以找到圆的半径。
example的中文翻译为:示例 public class main { //main method public static void main(string[] args) { //width (w) and height (h) of arc double w = 5, h = 2; //call the user defined method to get the radius findradius(w, h); } //find radius of circle static void findradius(double w, double h) { //find radius using the formula double r = ((w * w) / (8 * h) + h / 2); system.out.println( radius of the circle: +r); } }
输出 radius of the circle: 2.5625
在本文中,我们探讨了如何使用不同的方法在java中找到圆的半径,当圆的弧的宽度和高度已知时。
以上就是使用给定的弧的宽度和高度计算圆的半径的java程序的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product