Parabola Class issue

Hi all, my code builds fine, but when I go to run it, it gives me multiple errors. Not sure why, and after playing around with it for the past hour, I need a second opinion as to why it's not working. It's saying their is an unidentified reference to Parabola and set precision.

The program basically is calculating parabolas and seeing the concavity using a class.

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
#include <iostream>
using namespace std;

class Parabola{

private:
	double Coeff, aCoeff, bCoeff, cCoeff;
	double sqrt(double a);
	
public:
	Parabola(double a, double b, double c){
	if(a==0)
	Coeff = 1;
	else
	aCoeff = a;
	
	bCoeff = b;
	cCoeff = c;
	
}

double calcDiscrim(){
return( (bCoeff * bCoeff) - (4 * aCoeff * cCoeff) );

}

double calcRoots(double &root1, double &root2){
if(calcDiscrim()==0){
	root1 = -bCoeff / (2 * aCoeff);
	return 1; 
}
if(calcDiscrim()>0){
	root1 = (-bCoeff + sqrt(calcDiscrim())) / (2 * aCoeff);
	root2 = (-bCoeff + sqrt(calcDiscrim())) / (2 * aCoeff);
	return 2;
}
if(calcDiscrim()<0)
return 0;

}

double calcX(){
return (-bCoeff / (2 * aCoeff));
}

double calcY(){
return ((aCoeff * calcX()) + (bCoeff * calcX()) + cCoeff);
}

void printEquation(){

cout << aCoeff << "x^2 + " << bCoeff << "x + " << cCoeff << endl;
}

void printVertex(){

cout << "Vertex Coordinates: ("<< calcX() << "," << calcY() <<")" << endl;
}

void printRoots(){
double number;
double root1, root2;
double &a = root1;
double &b = root2;
int setprecision(int a);
number = calcRoots(a, b);

if(number==0)
cout << "There are NO real roots" << endl;

if(number==1)
cout << "There is one real root with X-Coordinate root_1_value" << fixed << setprecision(3) << &a << endl;

if(number==2)
cout << "There are two real roots with X-Coordinate root_1_value" << fixed << setprecision(3) << &a << "and root_2_value" << fixed << setprecision(3) << &b << endl;
}

void printConcavity(){
if(aCoeff < 0)
cout << "The parabola opens Downward" << endl;
else
cout << "The parabola opens Upward" << endl; 
}

void print(){
printEquation();
printVertex();
printConcavity();
printRoots();
}
};

int main(){
Parabola p1(1, 4, -5);
Parabola p2(0, 0, 25);
Parabola p3(-1, 2, -1);
Parabola p4(-12, -2, 3);
Parabola p5(12, 2, 3);

cout << "The first parabola:" << endl;
p1.print();

cout << "The second parabola:" << endl;
p2.print();

cout << "The third parabola:" << endl;
p3.print();

cout << "The fourth parabola:" << endl;
p4.print();

cout << "The fifth parabola:" << endl;
p5.print();
return 0;
}


Thank you for any help!
You can fix most of the errors by adding the missing headers:
1
2
#include <iomanip>
#include <cmath> 


Then delete lines 8 and 65:
double sqrt(double a); // delete this line

int setprecision(int a); // delete this line

That worked! Thank you very much!!!
Topic archived. No new replies allowed.