Hello, I've written a C++ class which 'estimates' the roots of a given number ...
It was called 'sqr' because it was first intended to estimate square roots only, but later on I made some little changes to my code which made it possible to estimate every root ...
So, some method's/variable's names are already deprecated, sorry for that ...
This is a sample program which demonstrates the use of the sqr class:
#include <iostream>
#include <cstdlib>
#include "sqr" /* Header file where the declarations of the sqr class reside in */
using namespace std;
int main()
{
double tmp;
sqr wortel_object(0);
system("CLS");
cout << "*** SQR-OBJECT DEMO ***" << endl;
cout << endl << endl << "Type n-root: ";
cin >> tmp;
wortel_object.setnsqr(static_cast <int> (tmp));
cout << endl << "Type a number: ";
cin >> tmp;
wortel_object.setsqr(tmp);
cout << endl << "Type the desired precision: ";
cin >> tmp;
wortel_object.setprecision(static_cast <int> (tmp));
cout.precision(10);
cout << endl << "The (estimated) " << wortel_object.getnsqr() << "th root of " << wortel_object.getsqr() << " is: " << wortel_object.estimate() << endl;
cout << endl << "The precision was: " << wortel_object.getprecision() << endl;
cout << endl << "The calculation time was: " << wortel_object.getcalctime() << " seconds ..." << endl << endl;
return 0;
}
P.S.: I put much effort in translating all the comments I made from Dutch to English, so sorry if my English is bad ...