00001 #include <math.h>
00002 #include "Riostream.h"
00003 #include "Quad.h"
00004
00005 Quad::Quad(Float_t a,Float_t b,Float_t c)
00006 {
00007 fA = a;
00008 fB = b;
00009 fC = c;
00010 }
00011
00012 Quad::~Quad()
00013 {
00014 cout << "deleting object with coeffts: "
00015 << fA << "," << fB << "," << fC << endl;
00016 }
00017
00018 void Quad::Solve() const
00019 {
00020 Float_t temp = fB*fB -4*fA*fC;
00021 if (temp > 0) {
00022 temp = sqrt(temp);
00023 cout << "There are two roots: "
00024 << ( -fB - temp ) / (2.*fA)
00025 << " and "
00026 << ( -fB + temp ) / (2.*fA)
00027 << endl;
00028 } else {
00029 if (temp == 0) {
00030 cout << "There are two equal roots: "
00031 << -fB / (2.*fA) << endl;
00032 } else {
00033 cout << "There are no roots" << endl;
00034 }
00035 }
00036 }
00037
00038 Float_t Quad::Evaluate(Float_t x) const
00039 {
00040 return fA*x*x + fB*x + fC;
00041 return 0;
00042 }