Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In Java create a program that will manage polynomials in three variables (x, y, and z) with non-zero integer coeficients, and non-negative integer exponents. Three

In Java create a program that will manage polynomials in three variables (x, y, and z) with non-zero integer coeficients, and non-negative integer exponents. Three variable polynomials are of the following form:

p(x,y,z) = c1xA1yB1zC1 + ··· + cnxAnyBnzCn

where ci is coeficient, and Ai, Bi and Ci represent the exponents of variables.


To simplify the project, we only deal with polynomials in the above form, under the following assumptions.


1. We assume that every term in a polynomial follows xyz sequence. We only deal with a term like 5x6y3z2, and we won’t deal with a term like 5y3x6z2.


2. We assume that a coeficient can only occur at the beginning of a term. We only deal with a term like 6x8y4z5. We won’t deal with a term like 3x8 · 2y4z5.


3. We assume that no term in a polynomial contains division operator. We won’t deal with a term like 4x3/(y7z5).



2 Requirements


2.1 Input Representation of Polynomials


The purpose of your program is to interact with users by inserting, deleting, updating, and searching named polynomials. By following the assumptions defined in Section 1, we can simplify how a polynomial can be input into the program. In a polynomial, each term is represented by 4 integers separated by commas:

• coeficient

• exponent for variable x • exponent for variable y • exponent for variable z

and multiple terms are separated by space characters. For example, if the polynomial is


A = 6x9y6z3 + 5x4z5 − 3


its input should be


A 6,9,6,3 5,4,0,5 -3,0,0,0


Your program must be able to handle/parse the input correctly.


2.2 Output Representation of Polynomials


The program output of polynomials is similar to standard mathematical form with simplifications. For example, if the polynomial is


B = −2x3y7z2 + x4z5 − 8y3z + 9


its output should be


B = - 2(x^3)(y^7)(z^2) + (x^4)(z^5) - 8(y^3)(z) + 9


To ensure correct output formats, please attend to the following items.


1. Pay attention to the usage of parentheses in the above example.


2. Pay attention to the spaces around operators in the above example.


3. If the coeficient of the first term is positive, do not display the plus sign for the first term. For example, B = 2(x^3)(y^7)(z^2) + (x^4)(z^5) - 8(y^3)(z) + 9


4. If the coeficient of a term is 0, do not display this term. An exception is that if the polynomial contains no terms at all, display 0.


5. If the coeficient of a term is 1, do not display the coeficient. The exception is that if the exponents of x, y and z are all 0, and the coeficient is 1, 1 must be displayed for this term. For example, B = - 2(x^3)(y^7)(z^2) + (x^4)(z^5) - 8(y^3)(z) + 1


6. If the exponent of a variable is 0, do not display this variable.


7. If the exponent of a variable is 1, just display the variable itself, and keep the parentheses.


2.3 Polynomial Management Operations


Your program must maintain a list of named polynomials. The management operations are as follows.


INSERT Insert a new polynomial into the list. If the insert operation is successful, output the polynomial. The insert operation can fail if there is already a polynomial in the list with the same name. In the case of an insertion failure, display the message POLYNOMIAL ALREADY INSERTED.


DELETE Delete an existing named polynomial from the list. If the delete operation is successful, display the message POLYNOMIAL SUCCESSFULLY DELETED. If the named polynomial does not exist, display the message POLYNOMIAL DOES NOT EXIST.


UPDATE Update an existing polynomial in the list. If it is found in the list, the existing poly-nomial is replaced by the newly entered one, and output the updated polynomial. If the polynomial does not exist, display the message POLYNOMIAL DOES NOT EXIST.


SEARCH Search for a named polynomial in the list. If it is found in the list, output the polyno-mial. If the polynomial does not exist, display the message POLYNOMIAL DOES NOT EXIST.


QUIT This command makes the program properly exit. The QUIT command should remove all the polynomials from the list, and then exit the program.


To review, the following examples are provided.


INSERT A 3,2,0,0 5,1,1,0 -8,0,2,0 4,1,0,0 -3,0,1,0 12,0,0,0

A = 3(x^2) + 5(x)(y) - 8(y^2) + 4(x) - 3(y) + 12

INSERT B 1,3,0,0 6,0,2,0 -15,1,0,0 11,0,0,0

B = (x^3) + 6(y^2) - 15(x) + 11

INSERT A 2,1,0,0 3,0,1,0 -5,0,0,0

POLYNOMIAL A ALREADY INSERTED


DELETE B

POLYNOMIAL B SUCCESSFULLY DELETED

DELETE C

POLYNOMIAL C DOES NOT EXIST


UPDATE A 1,1,0,0 -4,0,1,0 1,0,0,0

A = (x) - 4(y) + 1

UPDATE B 4,2,2,2 8,1,1,1 16,0,0,0

POLYNOMIAL B DOES NOT EXIST


SEARCH A

A = (x) - 4(y) + 1

SEARCH B

POLYNOMIAL B DOES NOT EXIST



3 Data Structures and Design


3.1 Term Class


Each polynomial is composed of many polynomial terms. You are to create a Term class that only holds the information for a polynomial term. This class should have necessary private fields for a polynomial term (1 coeficient and 3 exponents), proper constructors, getters, and setters. In addition, the class should also override the method toString(). It returns a String, which shows a polynomial term in proper format.


3.2 DLList Class


Use the implemented DLList class.


3.3 Polynomial Class


Building up from the Term class and DLList class, Polynomial is composed of two private fields:


1. The name of the polynomial


3



2. A doubly linked list of Terms.


Polynomial class should have proper constructors, getters, setters, and other useful methods if needed.


3.4 PolyList Class


Building up from the Polynomial class and DLList class, PolyList is a doubly linked list of Polynomials. This class should implement all the polynomial management operations.


3.5 Project3 Class


In this project, Project3 class should handle all the input from users. This class is also the entrance of the program.

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_2

Step: 3

blur-text-image_3

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

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

13th edition

1439078106, 111197375X, 9781439078105, 9781111973759, 978-1439078099

More Books

Students also viewed these Finance questions