5A_4_OOP
This commit is contained in:
parent
3e7e6a7200
commit
edca2d6ea6
|
@ -3,17 +3,20 @@
|
|||
|
||||
using namespace std;
|
||||
|
||||
int main()
|
||||
{
|
||||
cout << setprecision(2);
|
||||
class FunkcjaKwadratowa {
|
||||
float a, b, c;
|
||||
cout << "Podaj a: ", cin >> a;
|
||||
cout << "Podaj b: ", cin >> b;
|
||||
cout << "Podaj c: ", cin >> c;
|
||||
float delta;
|
||||
public:
|
||||
void podajDane(float a, float b, float c) {
|
||||
this->a = a;
|
||||
this->b = b;
|
||||
this->c = c;
|
||||
|
||||
cout << "Rownanie: " << a << "x^2 + " << b << "x + " << c << " = 0" << endl;
|
||||
this->delta = (b * b) - (4 * a * c);
|
||||
}
|
||||
|
||||
float delta = (b * b) - (4 * a * c);
|
||||
void rownanie() {
|
||||
cout << setprecision(2) << fixed;
|
||||
if (delta < 0) cout << "Brak pierwiastkow" << endl;
|
||||
else if (delta == 0) {
|
||||
float x = -b / (2 * a);
|
||||
|
@ -27,3 +30,16 @@ int main()
|
|||
cout << "2 pierwiastki: x1 = " << x1 << ", x2 = " << x2 << endl;
|
||||
}
|
||||
}
|
||||
|
||||
void wypisz() {
|
||||
cout << "Rownanie: " << a << "x^2 + " << b << "x + " << c << " = 0" << endl;
|
||||
}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
FunkcjaKwadratowa q;
|
||||
q.podajDane(4, 4, 1);
|
||||
q.wypisz();
|
||||
q.rownanie();
|
||||
}
|
Loading…
Reference in New Issue