Question: PART 2 : PolyCalculator ( 6 0 Marks ) Java You are tasked with implementing a simple polynomial calculator using linked lists in Java. Practically,

PART 2: PolyCalculator (60 Marks) Java
You are tasked with implementing a simple polynomial calculator using linked lists in Java.
Practically, there is a small change in the implementation of the linked list in this part compared
to the first part: the nodes contain 2 data values: the coefficient and the exponent of each term
in the polynomial. You can copy your implementation from part 1, making the necessary
changes to make it work for the given requirements.
You are required to implement the following member functions (methods) in the
PolyCalculator class as described below.
Each linked list (list1 and list2) in the PolyCalculator class represents a single polynomial
expression.
Storing the Polynomial in a Linked List:
A polynomial expression can be stored in a Linked List by representing each term as a node of
the linked list. Each node of the list contains the coefficient and exponent of each term,
respectively. For example, the expression +1x2-15x1+9x0 can be stored in a Linked List as
follows:
Member Functions to Implement:
Polycalculator():
Simple default constructor.
input():
Inputs the expression by the user in the format "+3x2+2x+1" and stores it in list1
and list2.
You can assume that the input will always have the same format (i.e.,[+ or -
][number]x). Valid expressions include: -4-2x4+3x2,+45x11. Invalidnumber
expressions include: 4x9,+2,+4x-5(you will not be tested on these).
add(LinkedListPoly I1, LinkedListPoly 12):
This function will add the expressions in the two polynomials stored in I1 and I2
and store the result in a new polynomial 'result'. It will return this new polynomial.
subtract(LinkedListPoly I1, LinkedListPoly I2):
This function will subtract the expressions in the two polynomials stored in I1 and
12(11-12) and store the result in a new polynomial 'result'. It will return this new
polynomial.
void print(LinkedListPoly I1):
This function will print the list stored in the LinkedListPoly '11' in the correct
format.
PART 2 : PolyCalculator ( 6 0 Marks ) Java You

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Finance Questions!