Answered step by step
Verified Expert Solution
Question
1 Approved Answer
j Univariate Polynomial A polynomial is a mathematical expression involving a sum of powers in one or more variables multiplied by coefficients. A polynomial in
j
Univariate Polynomial A polynomial is a mathematical expression involving a sum of powers in one or more variables multiplied by coefficients. A polynomial in one variable (i.e., a univariate polynomial) with constant coefficients is given by where, n is a nonnegtive integer and ao,aan are constant coeficients. Each part that is being added is called a term. The exponent on the variable in a term is called the degree of the term. The degree of a polynomial is the largest degree of the terms with non-zero coefficients. You are to implement the class Polynomial using template. Your class should be able to handle a various types of polynomials, i.e., a polynomial with short coefficents, a polynomial with int coefficents, a polyno- ith long coefficients, a polynomial with float coefficients, and a polynomial with double coefficients. In all cases, the degree of each term is always a non-negative integer. I strongly suggest that you complete this assignment in 2 parts. In part 1, you first develop Polynomial class for int coefficients only and test it thoroughly. In part 2, once you are satisfied with your implementation of part 1, convert it to a template class. 1 (60 points) Polynomial with int coefficients You are provided with two startup files and one object file: /home/cmpsc122/f17/hx2/polynomial.1.h /home/cmpsc122/f17/hw2/main.1.cxx /home/cmpsc122/f17/hw2/polynomial.1.o 1.1 (15 points) Test cases You can compile and run the startup programs using the following commands: $ g++-ansi -pedantic-wall main.1.cxx polynonial-1.o-o polynomi al $./polynonial main.1.cxx contains 13 test cases for the class Polynomial defined in polynomial.1.h and implemented in polynomial.1.o. Add your own test cases at the designated location in main.1.cxx. You must add at least 30 test cases to fully test the class including any fringe cases. Do not remove the test cases provided in main.1.cxx. 1.2 (45 points) Implementation Create a file called polynomial.1.cxx and implement all the member and friend functions that are defined in polynomial-1.h. Do not forget to #include the header file polynomial-1.h in polynoma1.1.cxx. Test your implementation with the test cases you wrote in 1.1. You can compile and run main.1.cxx with your own implementation of Polynomial using the following commands: $ gtt -ansi -pedantic -Wall main.1.cxx polynomial.1.cxx -o polynomial ./polynomial Your implementation should pass all the test cases provided as well as the test cases you wrote in 1.1. 2 (40 points) Polynomial using template You are provided with two startup files and one object file: /home/cmpsc122/f17/hu2/polynomial.2.h /home/cmpsc122/f17/hw2/main 2.cxx /home/cmpsc122/f17/hu2/polynomial.2.0Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started