Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- #include <string>
- #include <math.h>
- using namespace std;
- class Rownanie {
- public:
- double a;
- double b;
- double c;
- double x;
- double delta;
- double m1, m2;
- void Wprowadz()
- {
- cout << "Podaj a: " << endl;
- cin >> a;
- cout << "Podaj b: " << endl;
- cin >> b;
- cout << "Podaj c: " << endl;
- cin >> c;
- if (a == 0)
- {
- string wyjatek = "Dzielenie przez 0! Wprowadz inne a";
- throw wyjatek;
- }
- }
- double licz()
- {
- cout << "Licze delte: " << endl;
- delta = pow(b, 2) - (4 * a*c);
- return delta;
- }
- void zerowe()
- {
- if (delta > 0)
- {
- m1 = (-b - pow(delta, 1 / 2)) / 2 * a;
- m2 = (-b + pow(delta, 1 / 2)) / 2 * a;
- cout << "1 miejsce zerowe: " << m1 << endl;
- cout << "2 miejsce zerowe: " << m2 << endl;
- }
- else if (delta == 0)
- {
- m1 = -b / 2 * a;
- cout << "Miejsce zerowe: " << m1 << endl;
- }
- else if (delta < 0)
- {
- cout << "Brak miejsc zerowych" << endl;
- }
- }
- };
- int main()
- {
- Rownanie kappa;
- try
- {
- kappa.Wprowadz();
- kappa.licz();
- kappa.zerowe();
- }
- catch (string wyjatek)
- {
- cout << wyjatek << endl;
- }
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement