i want to add the polynomials with the coeff getA(),getB() and getC() with the +ve or -ve signs. and remove the terms with zero coff like 2x^2+5 not 2x^2+0x+5 in general like (+/-)ax^2(+/-)bx(+/-)c.
public String toString() {
if (getA().equals(DEFAULT_A)
&& getB().equals(DEFAULT_B)
&& getC().equals(DEFAULT_C)) {
return "0";
} else {
String poly = "";
if (!getA().equals(DEFAULT_A)) {
poly = getA().toString() + "x^2";
}
if (!getB().equals(MyDouble.zero)) {
if (getB().compareTo(MyDouble.zero)) {
return getB();
}
}
poly += getB().toString() + "x";
if (!getC().equals(MyDouble.zero)) {
poly += getC().toString;
}
return poly;
}
}