# Answer to Question #18461 in Java | JSP | JSF for Sayed Abdullah Almousawi

Question #18461

Write a Java program to add and multiply two polynomials. The rules are as follows:

1. Ask the user to enter two polynomials at a time. For each polynomial, ask the user to enter the number of terms n in the polynomial, then prompt the user n times for a pair of integers representing the coefficient and the exponent of a term. For instance, the term 2x4 has a coefficient of 2 and an exponent of 4.

2. Output the input polynomials as well as the sum and product of polynomials.

A sample input/output run is as follows.

For p1, enter # XXXXX polynomial terms (n>=0): 2

Enter coefficient: 1

Enter exponent: 1

Enter coefficient: 1

Enter exponent: 0

You entered: x + 1

For p2, enter # XXXXX polynomial terms (n>=0): 2

Enter coefficient: 1

Enter exponent: 1

Enter coefficient: -1

Enter exponent: 0

You entered: x - 1

p1 = x + 1

p2 = x - 1

p1+p2 = 2x

p1*p2 = x^2 – 1

3. The output polynomials must be sorted in descending order of exponent. Terms of the same exponent should be added together and the term

1. Ask the user to enter two polynomials at a time. For each polynomial, ask the user to enter the number of terms n in the polynomial, then prompt the user n times for a pair of integers representing the coefficient and the exponent of a term. For instance, the term 2x4 has a coefficient of 2 and an exponent of 4.

2. Output the input polynomials as well as the sum and product of polynomials.

A sample input/output run is as follows.

For p1, enter # XXXXX polynomial terms (n>=0): 2

Enter coefficient: 1

Enter exponent: 1

Enter coefficient: 1

Enter exponent: 0

You entered: x + 1

For p2, enter # XXXXX polynomial terms (n>=0): 2

Enter coefficient: 1

Enter exponent: 1

Enter coefficient: -1

Enter exponent: 0

You entered: x - 1

p1 = x + 1

p2 = x - 1

p1+p2 = 2x

p1*p2 = x^2 – 1

3. The output polynomials must be sorted in descending order of exponent. Terms of the same exponent should be added together and the term

Expert's answer

Unfortunately, your question requires a lot of work and cannot be done for free.

Submit it with all requirements as an assignment to our control panel and we'll assist you.

Need a fast expert's response?

Submit orderand get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

## Comments

Assignment Expert13.11.12, 18:53Dear visitor

Questions in this section are answered for free. We can't fulfill them all and there is no guarantee of answering certain question& but we are& doing our best. And if answer is published it means it was attentively checked by experts. You can try it yourself by publishing your question.

Although if you have serious assignment that requires large amount of work and hence cannot be done for free& you can submit it as assignment and our experts will surely assist you

ahmad9113.11.12, 18:38how much the answer will cost?

## Leave a comment