Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program to input pairs of polynomials and output: 1. Output them in canonical form. Then compute and output: 2. Their sum (add them)

Write a program to input pairs of polynomials and output: 1. Output them in canonical form.
Then compute and output:
2. Their sum (add them)
3. Their difference (subtract them) 4. Their product (multiply them).
Question: What do we mean by canonical form?
Answer: This is a representation where
(a) The polynomial is written from the highest powers to the lowest, and
(b) All terms with the same power are consolidated. If the consolidation leads to a zero coefficient, do not display that term.
Example: If the input were
-1+5x+20x^3-9x^2-2x+x^2-2x^3+x^9, You would change it to:
x^9+18x^3-8x^2+3x-1 The input:
Read the input from a file called input.txt in the same directory as your program.
Each line (terminated by a newline character) in the file will represent a polynomial. The line will contain a list of integers, which when taken in pairs, will represents the coefficient and exponent of each of the terms in the polynomial.
Processing and output:
You will process each pair of lines, representing two polynomials and will: 1. Output them first as they appear in the file and then in canonical form. Then compute and output, all in canonical form:
2. Their sum (add them)
3. Their difference (subtract them) 4. Their product (multiply them).
Output them to a file in your programs directory called output.txt

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

Step: 3

blur-text-image

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

Data Access Patterns Database Interactions In Object Oriented Applications

Authors: Clifton Nock

1st Edition

0321555627, 978-0321555625

More Books

Students also viewed these Databases questions

Question

Why is participant anonymity so important in market research?

Answered: 1 week ago

Question

Please answer all the bottom part.

Answered: 1 week ago

Question

Presentation Aids Practicing Your Speech?

Answered: 1 week ago