Specifications:

In this project you are required to write thejava programPoly.javato implementinteger polynomials, andthreeoperations+,-,*, respectively.

Specifically, your program will read two polynomials from a file named input.txt (under the same directory of the program). Then your program should create a file named output.txt (under the same directory of the program) and write the results to output.txt. Please check the attached sample files input.txt and output.txt.

In input.txt:

  • Firstline is the degree of f(x).
  • Second line is the coefficients of f(x), from the leading coefficient to the constant, separated by one blank space.
  • Third line is the degree of g(x).
  • Fourth line is the coefficients of g(x), from the leading coefficient to the constant, separated by one blank space.

In output.txt:

  • First line is the coefficients of f(x)+g(x), from the leading coefficient to the constant, separated by one blank space.
  • Second line is the coefficients of f(x)-g(x), from the leading coefficient to the constant, separated by one blank space.
  • Third line is the coefficients of f(x)*g(x), from the leading coefficient to the constant, separated by one blank space.

Remark: The leading coefficient should not be 0 unless the polynomial is 0.

Example 1: if f(x) = 2x andg(x) = -2x + 1, then f(x) + g(x) = 1 instead of 0x + 1. Thus the first line of output.txt should be 1 instead of 0 1.

Example 2: if f(x) = 2x + 2, g(x) = -2x-2, then f(x) + g(x) = 0 instead of 0x + 0. Thus the first line of output.txt should be 0 instead of 0 0.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.