Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For this homework assignment, you will create two classes that will work with each other. The first is a class you will write is called

For this homework assignment, you will create two classes that will work with each other.

The first is a class you will write is called CQuadratic, which represents a second-order quadratic equation (e.g., 3x2 + 2x + 9). CQuadratic will only have one constructor (type constructor), which will take the coefficients of the quadratic equation (e.g., 3, 2, 9) and assign them to its three private data members (the three coefficient variables). The class also has an Evaluate function that passes a value, say x, and returns the evaluated expression f(x) (e.g., for f(x) = 3x2 + 2x + 9). Lastly, it has a destructor that will display to stdout CQuadratic destructor!!!

The second class is called CMathStud which represents a math stud(ent : ). Every CMathStud has his/her own particular quadratic equation. The constructor for CMathStud will only require the first two coefficients (x2 and x) as arguments; the third is optional to provide (default to 0). CMathStud has a getMyValue method, which accepts a value for x and should return f(x) for the math students quadratic equation.

All you need to do is fill in the ??? for all files (including main) and make sure you include the proper headers within each file and preprocessor directives. As a note, youre required to code all implementation in the corresponding .cpp files. All header files are for function prototypes only. Your code should mimic the output below:

CQuadratic constructor!!! CMathStud constructor!!! CQuadratic constructor!!! CMathStud constructor!!! Stud1 Eval: 16.1528 Stud2 Eval: 47.1751 CMathStud destructor!!! CQuadratic destructor!!! CMathStud destructor!!! CQuadratic destructor!!!

Get all five files (main.cpp, cquadratic.h, cquadratic.cpp, cmathstud.h, and cmathstud.cpp) together in a multi-module project.

main.cpp

???

int main() { // Create an object CMathStud stud1(1,2); CMathStud stud2(3,4,5);

// Evaluation cout << "Stud1 Eval: " << stud1.getMyValue(3.14159) << endl; cout << "Stud2 Eval: " << stud2.getMyValue(3.14159) << endl << endl;

return 0;

} // end of "main"

cmathstud.h

class CMathStud { public: ???

private: CQuadratic QE; };

cquadratic.h

class CQuadratic { public: ???

private: int c1; int c2; int c3; };

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

Students also viewed these Databases questions