文本内容:
绪论实验答案//存放解class Solution//根个数int ent;double xl;//根2double x2;实验public class1_2{//求方程的根static Solution solvedouble a,double b,double cSolutions=new Solution;double d=b*b-4*a*c;if d0s.ent=0;abs//等于0else ifMath.d=
0.0001s.ent=1;sqrts.xl=-b+Math.d/2*a;}else{s.ent=2;sqrts.xl=-b+Math.d/2*a;sqrts.x2=-b-Math.d/2*a;return s;//输出结果static voiddisp Solutionsif s.ent==0“无根System.out.printin;else ifs.ent==1out.可艮为%.nSystem.printf——4If\n,s.xl;else・两个根为%nSystem,out:printf.If^H%.lf\n,s.xl,s.x2;public staticvoid mainString[]args{Solutions;double a=2,b=-3,c=4;测试System.out.printf\n l\n;nSystem.out.printf a=%.If,b=%.If,c=%.If”,a,b,c;s=solvea,b,c;disps;a=1;-2;c=1;测试System.out.printfH\n2\n”;out.System.printf s=a=%.lf,b=%.lf,c=%.lf”,a,b,c;solve dispa,b,c;s;a=2;b=-1;c=-1;System.out.printf\n测试n3\n;out.System.printf s=・a=%.If,b=%lf,c=%.If”,a,b,c;solvea,b,c;disps;。