Question: write a Java program. Create a polynomial class with linked lists and implement some basic functions. Specifications Polynomials are stored in a linked list of

write a Java program.

Create a polynomial class with linked lists and implement some basic functions.

Specifications

Polynomials are stored in a linked list of Term objects (two classes: Polynomial and Term).

Term objects have two data fields: coefficient and exponent, both positive integers.

Polynomial will have some methods that create linked list functionality, but not all list operations are needed; include only those used by this program.

Do not use a separate linked list class. The list will be non-circular. Make a decision on whether to use a doubly-linked list and/or a tail reference.

Read a polynomial from the user.

Read a polynomial from a file,

add two polynomials (output to screen and file)

evaluate a polynomial (output to screen and file).

Evaluate takes a value for x (the variable), then calculates the polynomials value. Input / output.

The program will work interactively (good for testing during development), and with files. All input (user and file) is guaranteed to be correct. Input files.

There will be two final input files, with the same format. The first input file is test data from you, and will be four add operations and four evaluate operations, in any order. This file is created from a test plan with eight cases. For each case, first, describe what you are testing (examples: adding with missing terms, adding with no common terms, evaluating with zero); second, give the specific data being tested; third, give the expected result.

Your program should not depend on a fixed number of add and evaluate operations. Ill do additional testing on submitted projects.

Each operation takes three lines in the file: Add has the word add (line #1), then the two polynomials in normal form (one per line). Evaluate has the word evaluate (line #1), followed by the polynomial (in normal form) to evaluate (line #2), followed by the x value (line #3). Output log file.

This file will record the operations you used for final testing (taken from the input file) and the results. It starts with a heading, which includes your name. Then, for each operation, it gives the operation (add or evaluate), the polynomial(s) used, the x value (for evaluate), and the result (new polynomial for the add operation, final value for evaluate).

Put a blank line between each operations data. Be sure to check this file to validate your answers.

Methods in the polynomial class. add two polynomials: some terms may be missing, polynomials may be different lengths read polynomial from file: prompt user for filename;

assumptions:

the file exists and is readable, the polynomials are correctly formatted read polynomial from user:

perfect user print polynomial coefficients of 1 do not print, terms with a zero coefficient do not print evaluate polynomial x values will be integers Polynomial syntax, normal form.

polynomials are ordered from high-order term to low-order term coefficients of one are not displayed x^2 not 1x^2 terms with zero coefficients are not stored or displayed 0x^3 superscripts use carets (^) white space exactly one space between terms and plus signs (input and output), no spaces in terms i.example:

25x^3 + 6x + 2

Further specifications.

main is in a separate driver class x will be the only variable no multiple terms of the same order (e.g., two x^2 terms) no subtraction in the polynomial Development.

Use incremental development: first create a design for program structure, then create a stubbed form of the program. Continue by creating and testing one operation at a time. Comment out the stubs once the methods are implemented.

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 Databases Questions!