Polynomial Addition and Subtraction I got more than 10 wrong answer for this que
ID: 3865640 • Letter: P
Question
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.
Explanation / Answer
#include<stdio.h>
#include<conio.h>
#include "poly.h"
void main()
{
clrscr();
Polynomial *p1,*p2,*sum,*sub,*mul;
printf(" ENTER THE FIRST POLYNOMIAL.");
p1=createPolynomial();
printf(" ENTER THE SECOND POLYNOMIAL.");
p2=createPolynomial();
clrscr();
printf(" FIRST : ");
displayPolynomial(p1);
printf(" SECOND : ");
displayPolynomial(p2);
printf(" ADDITION IS : ");
sum=addPolynomial(p1,p2);
displayPolynomial(sum);
printf(" SUBTRACTION IS : ");
sub=subPolynomial(p1,p2);
displayPolynomial(sub);
getch();
}