Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Overview For this assignment, write a set of functions that will be used by a pr

ID: 3652400 • Letter: O

Question

Overview



For this assignment, write a set of functions that will be used by a program that displays information about parabolas. The program calculates the X and Y-coordinates for the vertex of a parabola, determines the concavity of the parabola, and determines if the parabola has real roots and what they are if they exist.

As noted above, you are only required to write functions for this assignment. A driver program that contains the code necessary for main() can be found here. Download the driver program and add your functions to the end of it.

The Functions

double getA();

This function will get and return the a-coefficient of the parabola. It takes no arguments and returns a double: the valid a-coefficient.

The function should display a prompt to the user and accept a value. If the value the user enters is non-zero, it should be returned to the calling function. If the value the user enters is 0, display an error message that the a-coefficient must be non-zero and ask the user to re-enter the value. This should be repeated until non-zero value is entered.

double calcXvertex( double, double );

This function will calculate and return the X-coordinate of the vertex of the parabola. It takes two double arguments: the a-coefficient for the parabola and the b-coefficient for the parabola. It returns a double: the X-coordinate of the vertex of the parabola.

The formula for calculating the X-coordinate of the vertex is:

X-Vertex = -b-coefficient / ( 2 * a-coefficient)
double calcYvertex( double, double, double );

This function will calculate and return the Y-coordinate of the vertex of the parabola. It takes three double arguments: the a-coefficient for the parabola, the b-coefficient for the parabola, and the c-coefficient for the parabola. It returns a double: the Y-coordinate of the vertex of the parabola.

The formula for calculating the Y-coordinate of the vertex is:

Y-Vertex = ( a-coefficient * X-Vertex2 ) + ( b-coefficient * X-Vertex ) + c-coefficient
void printConcavity( double );

This function will display the concavity of the parabola. It takes one double argument: the a-coefficient for the parabola. It returns nothing.

If the a-coefficient is positive, then the parabola opens upward. If it's negative, then the parabola opens downward.

double calcDiscriminant( double, double, double );

This function will calculate and return the discriminant. It takes three double arguments: the a-coefficient for the parabola, the b-coefficient for the parabola, and the c-coefficient for the parabola. It returns a double: the discriminant.

The discriminant is the expression that is under the square root sign for the quadratic equation, so it's value is:

discriminant = b-coefficient2 - 4 * a-coefficient * c-coefficient
This function will not be called from main(). It is only used in the printRoots function.

void printRoots( double, double, double );

This function will display the root of the parabola if they exits. It takes three double arguments: the a-coefficient for the parabola, the b-coefficient for the parabola, and the c-coefficient for the parabola. It returns nothing.

The roots are the places where the parabola intersects the x-axis. If the parabola is entirely above or below the x-axis, there are no real roots. If it just touches the x-axis, it has one root with a multiplicity of 2. Otherwise, it cuts the x-axis at 2 points.

To determine which case holds true, calculate the discriminant by calling the calcDiscriminant function and check its value. If the discriminant is positive, there are two real roots. If it's 0, there is one real root with multiplicity 2 (i.e. either root formula from below can be used to calculate the root since the result will be the same with either formula). If it's negative, there are no real roots.

Use the following equations to calculate the roots:

root 1 = ( -b-coefficient + sqrt( discriminant )) / ( 2 * a-coefficient )

root 2 = ( -b-coefficient - sqrt( discriminant )) / ( 2 * a-coefficient )
Program Requirements

At the top of the C++ source code, include a documentation box like normal. Complete program documentation is required for this assignment, which includes documentation boxes for *EACH* function that explains:

its name
its use or function: that is, what does it do? What service does it provide to the code that calls it?
a list of its arguments briefly describing the meaning and use of each, and in particular whether the function modifies each one
the value returned (if any) or none.
notes on any unusual features, assumptions, techniques, etc.
/***************************************************************
Function:

Use:

Arguments:

Returns:

Notes:
***************************************************************/
The #include <cmath> at the top of the code is so that the sqrt function can be used to calculate a square root.

Explanation / Answer

#include #include #include using namespace std; double getA(); double calcXvertex(double,double ); double calcYvertex(double,double,double,double); void printConcavity(double ); void printRoots( double, double, double ); int main() { double aCoeff, bCoeff, cCoeff; double xVertex, yVertex; //cout