📄 squarequation.txt
字号:
package tom.jiafei;
public class SquareEquation{
double a,b,c;
double root1,root2;
boolean boo;
public SquareEquation(double a,double b,double c){
this.a=a;
this.b=b;
this.c=c;
if(a!=0){
boo=true;
}
else{
boo=false;
}
}
public void getRoots(){
if(boo){
System.out.println("是一元2次方程");
double disk=b*b-4*a*c;
if(disk>=0){
root1=(-b+Math.sqrt(disk))/(2*a);
root2=(-b-Math.sqrt(disk))/(2*a);
System.out.printf("方程的根:%f,%f\n",root1,root2);
}
else{
System.out.printf("方程没有实根\n");
}
}
else{
System.out.println("不是一元2次方程");
}
}
public void setCoefficient(double a,double b,double c){
this.a=a;
this.b=b;
this.c=c;
if(a!=0){
boo=true;
}
else{
boo=false;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -