advanced
placement computer science
linked
lists and polynomials
due: TBA
Create an
abstract data type [class] called Polynomial so that you can
represent polynomials with real coefficients. Design a class Term with
a real coefficient and an integer exponent to represent a term in a
polynomial. Represent a polynomial as
a LinkedList
using the LList class. Your Polynomial class will extend the LList class.
For example, the
polynomial 3.5x6 – 2.3x + 7 would be represented
by a list with three nodes having the values:
Provide
a method that constructs a polynomial from input values. Also
provide the following operations/methods in your Polynomial class:
Display the
resulting polynomial in a format like:
3.5x^6 – 2.3x + 7
Your test class GUI should provide textFields for the two polynomials as well as for the solution, and buttons for the above operations. Use type double for the coefficients.
skeletal project source code: Poly2008.zip
Formatting output:
public String configOutput(String poly)
{
String output = "<html>";
Scanner chopper = new Scanner(poly);
while(chopper.hasNext())
{String temp = (String)chopper.next();
temp=temp + " ";
int index = temp.indexOf("^");
if(index >=0)
{temp = temp.replaceAll("\\^","<sup>") + "</sup>";
}
output += temp;}
output+="</html>";
return output;
}
XTRA
credit: +10%
Display your polynomial in descending order by exponent.