Need help with

This is a project I'm working on and i am totally lost with functions, I do not even know where to go or if im doing any of this right. Any hints towards what I need to do would be very helpful. Thanks

Purpose: The purpose of this program is to create a quadratic
equation analyzer that will calculate the coordinates
of the vertex, the concavity, and the root(s) of a
parabola. The user supplies the 3 coefficients that are
needed for the calculations.

It should be displaying something similar to this:

Run 1:

Enter the a coefficient (non-zero value): 1
Enter the b coefficient: 4
Enter the c coefficient: -5

*******************************************
Quadratic Equation Analyzer
*******************************************
a Coefficient 1.000
b Coefficient 4.000
c Coefficient -5.000
-------------------------------------------
X Coordinate -2.000
Y Coordinate -9.000
-------------------------------------------
The parabola opens UPWARD
-------------------------------------------
Root 1 X Coordinate 1.000
Root 2 X Coordinate -5.000



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;

//*********************************************************************
//*
//*       Function Prototypes
//*
//*********************************************************************

double getA ();
double calcXvertex ( double, double );
double calcYvertex ( double, double, double );
void printConcavity ( double );
double calcDiscriminant ( double, double, double );
void printRoots ( double, double, double );


int main()
{
//*********************************************************************
//*
//* Variable Dictionary
//*
//* aCoeff, bCoeff, cCoeff  -  used to hold the coefficients
//*
//* xVertex  -  used to hold the X-coordinate of the vertex
//*
//* yVertex  -  used to hold the Y-coordinate of the vertex
//*
//*********************************************************************

double aCoeff, bCoeff, cCoeff;
double xVertex, yVertex;




//Setup the formatting

cout << fixed << setprecision(3);


//Get the A, B, and C coefficients from the user

cout << "Enter the a coefficient (non -zero value:\n";
cin >> aCoeff;

while (aCoeff >0)
	{
	cout << "Error: The a-value MUST be non-zero. Try Again:";
	cin >> aCoeff;
	} 
cout << "Enter the b coefficient: ";
cin >> bCoeff;
  
cout << "Enter the c coefficient: ";
cin >> cCoeff;


//Calculate the X and Y coordinates for the vertex of the parabola

xVertex = -bCoeff/(2 * aCoeff);
yVertex = (aCoeff * xVertex^2) + (bCoeff * xVertex) + cCoeff;


//Display the coefficients and vertices

cout << endl << "*******************************************"
     << endl << "        Quadratic Equation Analyzer"
     << endl << "*******************************************"
     << endl << "a Coefficient" << setw(30) << aCoeff
     << endl << "b Coefficient" << setw(30) << bCoeff
     << endl << "c Coefficient" << setw(30) << cCoeff
     << endl << "-------------------------------------------"
     << endl << "X Coordinate" << setw(31) << xVertex
     << endl << "Y Coordinate" << setw(31) << yVertex
     << endl << "-------------------------------------------";


//Display the concavity of the parabola

printConcavity( aCoeff );


//Display the roots

cout << endl << "-------------------------------------------";

printRoots( aCoeff, bCoeff, cCoeff );


cout << endl << endl;
return 0;
}

//***** Functions are coded below main() *****

double getA()
	{
  	cout << "Enter the a coefficient (non -zero value:\n";
	cin >> aCoeff;

	while (aCoeff >0)
		{
		cout << "Error: The a-value MUST be non-zero. Try Again:";
		cin >> aCoeff;
		} 

	return aCoeff;
	}

double calcXvertex ( double, double );
	{
	xVertex = -bCoeff / ( 2 * aCoeff);
	
	return xVertex;	
	}

double calcYvertex ( double, double, double );
	{
	yVertex = ( aCoeff * xVertex^2 ) + ( bCoeff * xVertex ) + cCoeff;
	
	return yVertex;	
	}

void printConcavity ( double );
	{
	if ( aCoeff > 0 )
		{
		cout << "Parabola opens UPWARD." << endl;	
		}	
	else 
		{
		cout << "Parabola opens DOWNWARD." << endl;	
		}	
		
	return 0;
	}

double calcDiscriminant ( double, double, double );
	{
	double discriminant;
	
	discriminant = bCoeff^2 - 4 * aCoeff * cCoeff;
	
	return discriminant;	
	}

void printRoots ( double, double, double );
	{
	if ( calcDiscriminant >	0 )
		{
		cout << "There are two real roots.";	
		}
	if else ( calcDiscriminant == 0 )
		{
		cout << "It has one root with a multiplicity of 2.";	
		}	
	else 
		{
		cout << "There are no real roots";	
		}	
	return 0;	
	}

Topic archived. No new replies allowed.