Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Polynomial Addition and Subtraction I got more than 10 wrong answer for this question This is Java #### Imp...#### It should Create and array or

Polynomial Addition and Subtraction

I got more than 10 wrong answer for this question

This is Java

#### Imp...#### It should Create and array or ArrayList of nodes, each node holding a term of the polynomial

Write a program that adds and subtracts two polynomials. Use the following interface:

public interface PolynomialInterface

{

PolynomialInterface add(PolynomialInterface other);

// Effect: Adds value to owner of addPolynomial method.

// Postcondition: Return value = this + value.

PolynomialInterface subtract(PolynomialInterface other);

// Effect: Subtracts value from owner of addPolynomial method.

// Postcondition: Return value = this - value. void readPolynomial();

// Postcondition: polynomial read.

String toString();

// Postcondition: polynomial converted to string.

}

Your code must use the Demo provided below.

public class PlynomialDemo { public static void main(String[] args) { // example strings constructor must handle // String s = "44"; // String s = "44x"; // String s = "4x^4+3x^3-3"; // String s = "4x^3-3x^11"; // String s = "44x^6-3x^10+4x^4"; // String s = "25x^5-3x^13+4x^12-78"; // String s ="34x^15-44x^14-3x^12+4x^31-78"; // String s1 = "44"; // String s2 = "44x-78"; // String s1 = "4x^4+3x^3-3"; // String s2 = "4x^6-3x^12"; String s1 = "4x^14-3x^12+4x^4+78"; String s2 = "-4x^4-3x^12+4x^17-78"; // String s1 = "4x^4+3x^11+4x^10"; // String s2 = "5x^14-3x^12+4x^19-78"; // String s1 = "4x^5+4x^4-3x^12-4x^41-78"; // String s2 = "-4x^4+3x^12+4x^41+78"; 
PolynomialInterface sortA1 = new ArraySortedPolynomial(s1); PolynomialInterface sortA2 = new ArraySortedPolynomial(s2); PolynomialInterface sortA3; sortA3 = sortA1.add(sortA2); System.out.println("Second test is sorted array of terms."); // System.out.println("sortA1 string is " + s1); System.out.println("sortA1 = " + sortA1); // System.out.println("sortA2 string is " + s2); System.out.println("sortA2 = " + sortA2); System.out.println("sortA3 = sortA1.add(sortA2) " + sortA3); sortA3 = sortA1.subtract(sortA2); // System.out.println("sortA1 string is " + s1); //System.out.println("sortA1 = " + sortA1); // System.out.println("sortA2 string is " + s2); //System.out.println("sortA2 = " + sortA2); System.out.println("sortA3 = sortA1.subtract(sortA2) " + sortA3); System.out.println(); 
 } } 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Understanding Oracle APEX 5 Application Development

Authors: Edward Sciore

2nd Edition

1484209893, 9781484209899

More Books

Students also viewed these Databases questions

Question

1. What is Ebola ? 2.Heart is a muscle? 3. Artificial lighting?

Answered: 1 week ago