Data StructuresProject 3 - Polynomial ManagementDue: March 21, Tuesday, by 11:30 PM1 BackgroundYour program will manage polynomials in three variables (x, y, and z) with non-zero...

Need done by deadline










Computer science 2nd year student



Data Structures Project 3 - Polynomial Management Due: March 21, Tuesday, by 11:30 PM 1 Background Your program will manage polynomials in three variables (x, y, and z) with non-zero integer coefficients, and non-negative integer exponents. Three variable polynomials are of the following form: p(x, y, z) = c1x A1yB1zC1 + · · ·+ cnxAnyBnzCn where ci is coefficient, 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 coefficient 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: • coefficient • 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 1 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 coefficient 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 coefficient 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 coefficient of a term is 1, do not display the coefficient. The exception is that if the exponents of x, y and z are all 0, and the coefficient 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. 2 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 coefficient 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 as described in Project 2. 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. 4 Assessment, Submission, and Grading • This is an individual project. • Your program must be written in Java. • It is NOT allowed to use arrays, or other Java built-in data structure classes such as List, ArrayList, Map or HashMap. • The given class design must be followed. • The grader will use command-line environment to grade your program. • The grader will strictly follow the aforementioned input and output format specifications. • Have sufficient comments in your code to facilitate others to understand it. • Compress your solution in a .zip file and submit it on TCU Online. The .zip file name is of your choice. • This project is worth 100 points. 4
Mar 21, 2023
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here