Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ object oriented programming question. You are to write a class called Binomial that will allow creation and handling of univariate binomial polynomials, as described

C++ object oriented programming question.

You are to write a class called Binomial that will allow creation and handling of univariate binomial polynomials, as described below. Binomial Description Each binomial object has following properties: Each binomial determined two coefficients and two variable exponents. Binomial power is always positive. Binomial power is always integer. Binomials cannot be added if they have different powers Class Details A Binomial class definition must be placed in the file binomial.h, and the method implementations must be located in file binomial.cpp. Specify an appropriate guard and a header reference in the above files. The single constructor for the Binomial class should have 4 parameters: two floating point coefficient values (optional, with a default value of 1.0); and two integer power values (optional, with a default value of 1). If the power value is less then 1, set the power to 1. You need to provide define corresponding members to make the class functional and kept track of the binomial parameters. There should be member functions GetCoefficient, and GetPower, which will return the corresponding binomial's coefficient value, and binomial's power value, respectively. Both methods must accept, as a parameter, an index of the term. The first term has index 1, the second term has index 2. If any other index value is specified the methods should return negative one, value, -1. The GetPower method should return an integer value of the corresponding term exponent. The GetCoefficient function should return a floating point value of the corresponding term coefficient. There should be member functions SetPower, which will set the corresponding binomial's exponent to the arbitrary positive value. If the exponent parameter is not positive then set the power to the default value 1. The method must accept two parameters: an index of the term and the term's exponent value. The first term has index 1, the second term has index 2. If any other index value is specified, the methods should not modify the power value of any term exponent. The method returns 0 if the term exponent is successfully set, otherwise return -1 There should be member function Add, which adds the one binomial to the other. The parameter of this member function need to be a constant reference to the other binomial object. The result of the addition is saved in the caller object. Method must return value 0 if operation is successfully terminated, otherwise the method returns -1. The binomial can only be added if they have the same power, otherwise the method returns -1. There should be two member functions Multiply (overrides), which each allow to multiply a binomial to a number and to a monomial. The first Multiply member function need to accept floating point parameter that is used to perform multiplication of the real number on the the binomial object. The second Multiply member function need to accept a two parameters: a floating point parameter - the monomial term coefficient value, and an integer parameter - the monomial term power value. The result of the multiplication is saved in the caller object. Your class declaration and definition files must work the provided test driver in the main.cpp file. Most questions about the required behavior of the class can be determined by carefully examining my test driver program and the sample execution. Your class must meet the requirements listed above in the specification. Test Press Run button to execute and test your program. Or run make test command in the command line to verify the correctness of your program.

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

Learning MySQL Get A Handle On Your Data

Authors: Seyed M M Tahaghoghi

1st Edition

0596529465, 9780596529468

More Books

Students also viewed these Databases questions

Question

1 . Television News channels importantance of our Life pattern ?

Answered: 1 week ago

Question

1. How is the newspaper help to our daily life?

Answered: 1 week ago

Question

1. Prepare a short profile of Mikhail Zoshchenko ?

Answered: 1 week ago

Question

What is psychology disorder?

Answered: 1 week ago