为了让它打印多个值,您首先需要填写“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);
}
}
只是从我的头上写的还没有检查它,只是为了给你一个样本:)
编辑使用其他答案来初始化您的数组。