Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a JAVA singly linked list program to accomplish addition, subtraction, and multiplication of two polynomials . Each term will be a node in the

Write a JAVA singly linked list program to accomplish addition, subtraction, and multiplication of two polynomials . Each term will be a node in the list.

After you parse the strings, you should insert the terms in order by power into your list. You should implement insertion sort for this part. An ordered list will be helpful when it comes to adding and subtracting.

The input will be two polynomials in string form:

X^5+2X^2+3X^3+4X^4

2X^2+4X

The output will should be:

Sum:X^5 + 4.0 X^4 + 3.0 X^3 + 4.0 X^2 + 4.0 X

Difference: X^5 + 4.0 X^4 + 3.0 X^3 -4.0 X

Product: 2.0 X^7 + 12.0 X^6 + 22.0 X^5 + 16.0 X^4 + 8.0 X^3

1) Term class is used to store your term for the polynomial. It should contain both the coefficient and power.

2) The node class will hold a term object as its data

3) The LinkedList class will be a list of all the terms in the polynomial. The class implements the LinkedList Interface

4) The Polynomial Class hold the linked list that is associated with that polynomial. It implements the Polynomial interface. This is where all the arithmetic will be done.

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

Oracle Database 19c DBA By Examples Installation And Administration

Authors: Ravinder Gupta

1st Edition

B09FC7TQJ6, 979-8469226970

Students also viewed these Databases questions