double [] readCoeffs(){//读取系数方法从这里开始
double[]coeffsArray1 = new double[3];
try {
System.out.print("Please enter a real number for the A coefficent of your quadratic equation: ");
coeffsArray1[0] = in.nextDouble();
System.out.print("Please enter a real number for the B coefficent of your quadratic equation: ");
coeffsArray1[1] = in.nextDouble();
System.out.print("Please enter a real number for the C coefficent of your quadratic equation: ");
coeffsArray1[2] = in.nextDouble();
}
catch(NumberFormatException e){
System.out.println("Please enter real numbers for all of your coefficients.");
}
return coeffsArray1;
}
public void run(){ 而(真){
尝试{ // double [] coeffsArray = new double [3]; //实例化一个双数组来存储传入的系数
for (int i =0; i<2; i++){ //outer loop runs as many times as the number of equations you want to solve
coeffsArray = readCoeffs(); //run read coefficient method each time you want coefficients for each equation. Reuse the same area for storing and sengind coeeficients through the pipes
for(int k=0; k<3; k++){ //inner loop
outfirst.writeDouble(coeffsArray[k]); // Pipe's end object is written into with double coefficients individually from the equations array through a data stream
}
} //closes for loop
睡眠(1500); //睡眠500毫秒 outfirst.flush(); //刷新管道让下一个线程不能继续 } //结束尝试