Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Software packages such as Mathematica and Maple have features that allow a user to manipulate symbolic algebraic expressions. For example, the user can enter a

Software packages such as Mathematica and Maple have features that allow a user to manipulate symbolic algebraic expressions. For example, the user can enter a pair of polynomials, say x2 + 1 and 3x4 +7 and software will print out 3x4 +x2 +8. In this programming project, we will develop a way of accomplishing this using linked lists. The idea is to represent each term in the polynomial using a node structure containing a field for the coefficient and a field for the exponent.

Begin by writing an interface called Polynomial that specifies these public methods. LinkedPolynomial will then implement the Polynomial interface. 1. getCoefficient - takes an integer argument and returns the coefficient of the term that has the argument as its exponent. 2. value - takes a double argument and returns the value of this polynomial at the argument 3. add - takes a LinkedPolynomial; returns a new Polynomial that is the sum of this and the argument. 4. subtract - takes a LinkedPolynomial; returns a new Polynomial that is the difference of this and the argument. 5. negate - returns the negative of the LinkedPolynomial 6. equals - takes a Polynomial; returns true if the Polynomials are equal, false otherwise. 7. hashCode - returns a hash code for the Polynomial 8. toString - returns a String representation of the Polynomial

Implement a class called LinkedPolynomial. LinkedPolynomials are to be immutable. LinkedPolynomial is to implement the Polynomial interface. You are not to use any of the Java Collections Framework for this assignment. You are to implement your linked list directly. The class LinkedPolynomial will have an integer exponent field and a double coefficient field. The constructor for LinkedPolynomial should take a String argument representing the polynomial. The strings will be formatted like this: (3.5, 4, 1.0, 2, 8.6, 0). Successive pairs represent a single term. This sequence represents 3.5x4 + x2 + 8.6.

Write a main method to test your code. Test your code thoroughly! You will be graded on the completeness of your tests.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

How To Build A Million Dollar Database

Authors: Michelle Bergquist

1st Edition

0615246842, 978-0615246840

More Books

Students also viewed these Databases questions

Question

What is the relationship between diversity, inclusion, and equity?

Answered: 1 week ago