Java 数学我做了这个程序,但需要知道多一点
我解决了这个问题,但我只找到了一个Java 数学我做了这个程序,但需要知道多一点,java,Java,我解决了这个问题,但我只找到了一个x值的方法?这是节目单 public class PointsOnACircleV1 { public static void main(String[ ] args) { double r = 1; double x = 0.1; double equation1= Math.pow(r,2); double equation2= Math.pow(x,2); double y = Math.sqrt(e
x
值的方法?这是节目单
public class PointsOnACircleV1 {
public static void main(String[ ] args)
{
double r = 1;
double x = 0.1;
double equation1= Math.pow(r,2);
double equation2= Math.pow(x,2);
double y = Math.sqrt(equation1-equation2);
System.out.println(y);
}
}
我得到了正确的答案
我需要我的来显示x的多个值。下面是输出应该是怎样的。如果可以,请提供帮助。使用
循环
相关文档
使用循环
相关文档
为了让它打印多个值,您首先需要填写“String[]args”,但您需要将它们设为double,以便能够将它们与其他值相乘。在您的例子中,这是X值,所以让我们来看看您发布的代码
public class PointsOnACircleV1 {
//initialize your array with your values
double [ ] args = { 1.0, 0.9, 0.8,.... and so on until you reach 0.1, 0.0};
//you could fill it other more effective ways but just to show you!
public static void main(double[ ] args)
{
double r = 1;
// no need to fill this as you already done
// it double x = 0.1;
for(Iterator<double> i = args.iterator(); args.hasNext(); )
{
//this is the number you want to multiply with
double numbertomultiply = args.next();
double equation1= Math.pow(r,2);
double equation2= Math.pow(numbertomultiply,2);
double y = Math.sqrt(equation1-equation2);
System.out.println(y);
}
}
公共类PointsOnACircleV1{
//使用值初始化数组
double[]args={1.0,0.9,0.8,…,依此类推,直到达到0.1,0.0};
//你可以用其他更有效的方法来填充它,但只是为了向你展示!
公共静态void main(双[]参数)
{
双r=1;
//不需要像你已经做的那样填写这个
//它乘以x=0.1;
for(迭代器i=args.Iterator();args.hasNext();)
{
//这是您要与之相乘的数字
double numbertomultiply=args.next();
双方程1=数学功率(r,2);
双方程2=数学功率(numbertomultiply,2);
双y=数学sqrt(方程1-2);
系统输出打印项次(y);
}
}
刚从我头上写下来,我没有检查过,只是给你一个样本:)
编辑使用其他答案来初始化数组。为了让它打印多个值,您首先需要填充“String[]args”,但您需要将它们设为双精度,以便能够将它们与其他值相乘。在您的情况下,这是X值,所以让我们来看看您发布的代码
public class PointsOnACircleV1 {
//initialize your array with your values
double [ ] args = { 1.0, 0.9, 0.8,.... and so on until you reach 0.1, 0.0};
//you could fill it other more effective ways but just to show you!
public static void main(double[ ] args)
{
double r = 1;
// no need to fill this as you already done
// it double x = 0.1;
for(Iterator<double> i = args.iterator(); args.hasNext(); )
{
//this is the number you want to multiply with
double numbertomultiply = args.next();
double equation1= Math.pow(r,2);
double equation2= Math.pow(numbertomultiply,2);
double y = Math.sqrt(equation1-equation2);
System.out.println(y);
}
}
公共类PointsOnACircleV1{
//使用值初始化数组
double[]args={1.0,0.9,0.8,…,依此类推,直到达到0.1,0.0};
//你可以用其他更有效的方法来填充它,但只是为了向你展示!
公共静态void main(双[]参数)
{
双r=1;
//不需要像你已经做的那样填写这个
//它乘以x=0.1;
for(迭代器i=args.Iterator();args.hasNext();)
{
//这是您要与之相乘的数字
double numbertomultiply=args.next();
双方程1=数学功率(r,2);
双方程2=数学功率(numbertomultiply,2);
双y=数学sqrt(方程1-2);
系统输出打印项次(y);
}
}
刚从我头上写下来,我没有检查过,只是给你一个样本:)
编辑使用其他答案初始化数组。是您需要掌握的概念。是您需要掌握的概念。