Answered step by step
Verified Expert Solution
Question
1 Approved Answer
100 COSC 2336.001 Programming Assignment II DUE DATE: Friday, 10 March 2023 A polynomial of degree a can be expressed in descending order as:
100 COSC 2336.001 Programming Assignment II DUE DATE: Friday, 10 March 2023 A polynomial of degree a can be expressed in descending order as: " + ... tax tax tax + e where the a's are integer coefficients. You are to write a complete Java program that allows input of an arbitrary number of polynomials coefficient/ exponent pairs. Such solution should implement two classes (polynomial and tomm) each with appropriate methods. Each polynomial should be constructed as a dynamic linked list of coefficient/exponent term nodes in descending order by exponent. Note that the coefficient/exponent pairs need not be input in d descending order is the responsibility of the Polynomial class to arrange the modes in that order. The polynomial class should algo be able evaluate each the polynomials for an arbitrary integer argument x and be able to output each of the polynomials in the appropriate descending order by exponent. For example, suppose the input data for a given polynomial was: 512360-32-1-13 The first value of each integer pair will represent the coefficient of a form and the second value will indicate the exponent of that tomm. The negative pair signals the termination of the polynomial data pairs. The value following that flag pair will be the integer value of x for which the polynomial will be evaluated. Thus, the output for this example would appear as: 2*X-3 + (-3) *X-2 + 5-X + 6 = 48 FOR X = 3 In order to efficiently manage the dynamic memory allocated for your linked lists during program execution, each term mode should be detached for garbage collection after the tomm represented by its coefficient/exponent pair is printed and evaluated for x. Data for this lab assignm ment can be found in the file named "lab2. txt". All input and output should be with files. Please note these special output requirements: The \\+ sign separates terms in each printed polynomial. If the coefficient of a term is 1, then do not print that coefficient. (e-g., 1- = *) If the coefficient of a term is 0, then do not print that term. the exponent of a term is 1, then do not print that exponent. (e.g., *1= x) If the exponent of a term is 0, then do not print the variable of that term. (e.g., 3'X*0 = 3) Print negative coefficient values in parentheses - - e.g. (-3)-x*2 Be sure to follow the techniques of good programming style and use extensive comments to provide for internal documentation of your source program. For evaluation of this lab assignment, you will be required to separately provide Your source program (.java] file (8), input file, and output file screenshots of output) via Canvas submission. Please submit there deliverables on or before the assignment due date
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started