QuestionQuestion

You will implement and test a preliminary version of the polynomial class, using a small array to store the coefficients of the polynomial in order of increasing exponents, following the design pattern of object-oriented approach. Suppose the range of the exponents is in [0, 30).

• Use an array as a private member variable.
• insert(), adding a new term on specific exponent.
• remove(), deleting a term.
• Have a add() method, deciding the parameters and the return value by yourself.
• Have a sub() method, deciding the parameters and the return value by yourself.
• A printout() method to display the polynomial expression.
• And other variables, or methods if needed.
• Do the algorithm analysis on the implemented method, and give the big O notation estimation.

You will also need to write a PolynomialTest program to initialize two linear polynomial objects and apply the operation on it and also display the result. For example, P1=x + 3x⁵ - 5x⁸; P2= 2x³ - 4x⁵+ 2x⁷; So P3= P1+P2= x +2x³ - x⁵+ 2x⁷ - 5x⁸, P4 = P1-P2 = x - 2x³ + 7x⁵- 2x⁷ - 5x⁸.

In this project, only one variable is considered, we don’t have the polynomial such as x+3x⁵ 3y³ .

Solution PreviewSolution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

public class Polynomial {
    private int [] terms;   
   
    /**
    * constructor
    * Suppose the range of the exponents is in [0, 30).
    */
    public Polynomial() {
       terms = new int[30];      
       for (int i = 0; i < terms.length; i++) {
            terms[i] = 0;
       }
    }
   
    /**
    * adding a new term on specific exponent.
    * @param term
    * @param exponent
    */
public void insert(int term, int exponent){
       if (exponent < 0 || exponent >= 30) {
            throw new ArrayIndexOutOfBoundsException("exponent must be a positive number and less tahn 30");
       }
       terms[exponent] = term;      
    }...
$23.00 for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Java Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats