我正在尝试将随机创建的双打写入 txt 文件,但我不知道这样做的最佳方法,因为必须重复将双打写入文件
这是我的生成器代码
public class DataGenerator
{
public static void main(String[] args)
{
// three double values are read from command line m, b, and num
double m = Double.parseDouble(args[0]); // m is for slope
double b = Double.parseDouble(args[1]); // b is y-intercept
double num = Double.parseDouble(args[2]); // num is number of x and y points to create
double x = 0;
double y = 0;
for (double count = 0; count < num; count++) // for loop to generate x and y values
{
x = Math.random() * 100;
y = (m * x) + b; // slope intercept to find y
System.out.printf("\n%f , %f", x, y);
System.out.println();
}
}
}