import java.util.*;import java.text.*;public class Polynomial{private Monomial head;private double TOLERANCE = 0.00000001;/***** the Monomial (inner) class ********************************/private class Monomial{private DecimalFormat precision = new DecimalFormat("#.####");private int exp; // coeff * x^expprivate double coeff;private Monomial next;public Monomial(int exp, double coeff, Monomial next){this.exp = exp;this.coeff = coeff;this.next = next;}public String toString(){String form = precision.format(Math.abs(coeff));if(exp == 0) return form ;elseif(exp == 1) return form + "*x";elsereturn form +"*x^" + exp;}public boolean equals(Monomial mono){return exp == mono.exp && coeff == mono.coeff;}}public Polynomial(){head = null;}/************************************************************************ inserts a new term into the polynomial. The polynomial should already* be sorted in order from largest to smallest exponent.***********************************************************************/public void insertTerm( double coeff, int exp ){//If the coeffiect is too big break out of this function now!if( Math.abs(coeff) < TOLERANCE ){return;}//If the head of list points to oblivion/NULL or the new exponent is less than the the current headexponentif( head == null || exp < head.exp ){//Insert a newhead = new Monomial(exp, coeff, head);return;}Monomial cur = head;Monomial prev = null;while( cur != null && exp > cur.e ...
To Order an Original Plagiarism Free Paper on the Same Topic Click Here












Other samples, services and questions:
When you use PaperHelp, you save one valuable — TIME
You can spend it for more important things than paper writing.