Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

How to add and multiply polynomial on a arraylist in java expert can show me an

ID: 3653448 • Letter: H

Question

How to add and multiply polynomial on a arraylist in java expert can show me an example.

Explanation / Answer

import java.util.ArrayList; public class SparsePolynomial { private ArrayList polynomialarraylist = new ArrayList(); /** * Constructor to get values of an arraylist of integers * @param arraylist that contains the integer values used for the polynomials */ public SparsePolynomial(ArrayList arrayList) { //MODIFIDED: polynomialarraylist //EFFECT: constructs the arraylist of polynomials based off the arraylist of integers insertIntoPolynomialArray(arrayList); } /** * Converts the elements of the integer array into polynomials * @param arrayList that contains the polynomials contents */ private void insertIntoPolynomialArray(ArrayList arrayList) { //MODIFIED: polynomialarray //EFFECT: inputs the values of the arrayList into the polynomial array based on the position of the digits for(int i = 0; i 0) result = result+ " + " + ( getCoefficient(j)); else if (getCoefficient(j) < 0) result = result+ " - " + (-getCoefficient(j)); if(getDegree(j) == 1) result = result + "x"; else if (getDegree(j) > 1) result = result + "x^" + getDegree(j); } return result; } /** * Sorts array * @param array to sort */ private void sort() { ArrayList temp = polynomialarraylist; ArrayList temp2 = new ArrayList(); int polydegreemain = polynomialarraylist.get(0).degree(); temp2.add(polynomialarraylist.get(0)); for(int i = 1; i polynomialarraylist.size()) { break; } int polydegreesecondary = polynomialarraylist.get(i).degree(); if(polydegreemain
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote