# parabola ifndef _PARABOLA_H define _PARABOLA_H class parabola private

 ``` 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``` ```// parabola.h #ifndef _PARABOLA_H #define _PARABOLA_H class parabola { private: double p, d; public: parabola(); parabola(double p); void getYByX(double x); void setP(double p); void setD(double d); void getXByY(double y); void operator+=(double d); void operator-=(double d); }; #endif /* _PARABOLA_H */ // parabola.cpp #include "parabola.h" #include #include #include using namespace std; parabola::parabola() { } parabola::parabola(double p) { this->setP(p); this->setD(0); } void parabola::setP(double p) { if (p != 0) this->p = p; else { cout << "Error. Wrong value is failed."; exit(0); } } void parabola::setD(double d) { this->d = fabs(d); } void parabola::getYByX(double x) { double y1, y2; if (p * (x - d) >= 0) { y1 = -(sqrt(2 * p * (x - d)) + d); y2 = sqrt(2 * p * (x - d)) + d; cout << "x = " << x << endl; cout << "y1 = " << y1 << ";y2 = " << y2 << endl; } else { cout << "Error. Invalid p or x values."; exit(0); } } void parabola::getXByY(double y) { double x; x = pow((y-d), 2) / (2 * p)+d; cout << "y = " << y << endl; cout << "x = " << x << endl; } void parabola::operator+=(double d) { this->d = d; } void parabola::operator-=(double d) { this->d = -d; } // main #include #include #include #include "parabola.h" using namespace std; int main(int argc, char** argv) { parabola p(1); p+=6; p.getXByY(8); return 0; } ```