Java: Creating a toString method for Polynomial class
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/5525210/java-creating-a-tostring-method-for-polynomial-class">Java: Creating a toString method for Polynomial class.</a>  </p>
</blockquote>



<pre><code>public String toString(){
        String mytoString="";
        if(!a.equals(0)){
            mytoString = a.toString() + "x^2";
        }
        if(!b.equals(0)){
            mytoString += b.toString() + "x";
        }
        if(!c.equals(0)){
            mytoString += c.toString(); 
        }
        return mytoString;
    }
</code></pre>

<p>This is the code I have.
The release tests for the project says I'm failing toStringPositive.
I'm having trouble figuring out what exactly is wrong with my code.
Any help is appreciated.</p>

<p>I have to create a string representing the Polynomial ax^2+bx+c.
These are the <strong>specifications</strong>:</p>

<ul>
<li>There are never any spaces in the
string.</li>
<li>Do not include an "*" in the "x^2"
and "x" terms.  (i.e., create
"23x^2", not "23*x^2").   If there
are negative terms, they should be
represented by subtraction, not
addition of a negative term (i.e.,
create "2x^2+4x-6", not "2x^2+4x+-6".</li>
<li>If there are any terms with a 0
coefficient, then skip that term
(i.e., create "2x^2-6", not
"2x^2+0x-6").</li>
<li>If all 3 coefficients are 0, then the
string should be "0" If there are any
terms with a 1 coefficient, then
display that coefficient (i.e.,
create "2x^2+1x+3", not "2x^2+x+3").</li>
<li>If the decimal component of a
coefficient is 0, then do not include
a decimal portion for that
coefficient (i.e., create "23x", not
"23.0x").  Note that the
MyDouble.toString() method does this
for you automatically.</li>
</ul>
