Need help with calling the toString method from my class into my main method...Plz HELP

Im writing a program where you input four coefficients and it evaluates x for f(x) and then prints a table.....Before this table is printed however, I need to call the equasion from a toString method and print it into output using System.out.println(toString). Everytime I compile the main program i get this error cannot find symbol
symbol  : method toString(java.lang.String)
location: class Polynomial

The Class compiles fine....

Here is my code....

import java.util.Scanner;
import java.text.DecimalFormat;

public class Poly
      public static void main (String[] args)
double c4,c3,c2,c1,c0,x,interval,xvalue;
int ptnumber,counter;
String result;

DecimalFormat fmt = new DecimalFormat ("0.##");

Scanner scan = new Scanner (;

System.out.print ("Enter the coefficient of x^4(0.0 if none:");
c4 = scan.nextDouble();

System.out.print ("Enter the coefficient of x^3(0.0 if none:");
c3 = scan.nextDouble();

System.out.print ("Enter the coefficient of x^2(0.0 if none:");
c2 = scan.nextDouble();

System.out.print ("Enter the coefficient of x^1(0.0 if none:");
c1 = scan.nextDouble();

System.out.print ("Enter the constant:");
c0 = scan.nextDouble();

System.out.print ("Enter the starting value of x:");
x = scan.nextDouble();

System.out.print ("Enter the number of points to be graphed(Integer):");
ptnumber = scan.nextInt();

System.out.print ("Enter the interval between points:");
interval = scan.nextDouble();

Polynomial pn = new Polynomial(c4, c3, c2, c1, c0);


System.out.println("x      | f(x)");
counter = 0;
while (counter < ptnumber)

System.out.println(x            +"      | "+fmt.format(pn.evaluate(x)));

x = (x + interval);


import javax.swing.JPanel;
import java.awt.*;
import java.text.DecimalFormat;

import java.text.DecimalFormat;
public class Polynomial
   double coeff4, coeff3, coeff2, coeff1, constant;
   public Polynomial(double c4, double c3, double c2, double c1, double c0)
            coeff4 = c4;
            coeff3 = c3;
            coeff2 = c2;
            coeff1 = c1;
            constant = c0;
      public double evaluate(double x)
            double xsq = x*x;
          return (coeff4*xsq*xsq + coeff3*xsq*x + coeff2*xsq + coeff1*x + constant);
      public String toString()
         //String result = "";
            String result =  (coeff4 + "*x^4 + " + coeff3 + "*x^3 + " + coeff2 + "*x^2 + " + coeff1 + "*x^1 + " + constant);
            return result;
  public void draw(Graphics page, int xPixels, int yPixels)
    final int NUM = 11;
    final double INTERVAL = 0.5;
    final double XSTART = 0.0;

    final int XMARGIN = 70;
    final int XUSABLEPIXELS = xPixels - 2*XMARGIN;
    final int YMARGIN =40;
    final int YUSABLEPIXELS = yPixels - 2*YMARGIN;
        // Label the graph
    page.drawString("Graph of f(x) = " + toString(), XMARGIN + 20, YMARGIN);

    // Draw the x axis and put in hash marks
    page.drawLine(XMARGIN, yPixels - YMARGIN, xPixels - XMARGIN, yPixels - YMARGIN);
    for ( int i = 0; i < NUM; i++ )
        page.drawLine(XMARGIN + i * XINTERVALPIXELS, yPixels - YMARGIN, XMARGIN + i * XINTERVALPIXELS, yPixels - YMARGIN + 5);
       DecimalFormat twoPlaces = new DecimalFormat("0.00");

    // Label the x axis
    for (int i = 0; i < NUM; i++)
        page.drawString( twoPlaces.format(XSTART + i * INTERVAL), 3 * XMARGIN / 4 + i * XINTERVALPIXELS, yPixels - YMARGIN/2);

    // Draw the y axis
    page.drawLine(XMARGIN, YMARGIN, XMARGIN, yPixels - YMARGIN);

    // Label the y axis and put in hash marks
    final double YMIN = 0.0;
    final double YINTERVAL = 100.0;

    for (int i = 0; i < NUM; i++)
        page.drawString(twoPlaces.format(YMIN + i * YINTERVAL), XMARGIN / 4, yPixels - i * YINTERVALPIXELS - YMARGIN);
        page.drawLine(XMARGIN, yPixels - YMARGIN - i * YINTERVALPIXELS, XMARGIN - 5, yPixels - YMARGIN - i * YINTERVALPIXELS);

    // your code

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

the default implementation doesn't take any argument, if you want toString of result varaible, you should just call


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.