import mathutils.Equation;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
// 读取用户输入的a, b, c值
System.out.print("请输入a的值: ");
double a = scanner.nextDouble();
System.out.print("请输入b的值: ");
double b = scanner.nextDouble();
System.out.print("请输入c的值: ");
double c = scanner.nextDouble();
// 创建Equation对象
Equation equation = new Equation(a, b, c);
try {
// 求解二次方程
double[] roots = equation.solveQuadraticEquation();
System.out.println("方程: " + equation);
System.out.println("根 1: " + roots[0]);
System.out.println("根 2: " + roots[1]);
} catch (IllegalArgumentException e) {
System.out.println(e.getMessage());
} finally {
// 关闭Scanner
scanner.close();
}
}
}