home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C++ / Libraries / continued_fraction / main.cp < prev   
Encoding:
Text File  |  1994-11-08  |  721 b   |  37 lines  |  [TEXT/KAHL]

  1. #include <math.h>
  2.  
  3. #include <iostream.h>
  4.  
  5. #include "continued_fraction.h"
  6.  
  7. void main()
  8. {
  9.     Boolean done = false;
  10.  
  11.     while( !done)
  12.     {
  13.         long double input;
  14.         cout << "\nGive a number and the maximum relative error wished for.\n"
  15.                 "Example: '3.1415927 0.0001'\n"
  16.                 "Input a non-positive number to exit the program\n";
  17.         cin >> input;
  18.         if( input <= 0.0)
  19.         {
  20.             done = true;
  21.         } else {
  22.             long double error;
  23.             cin >> error;
  24.             continued_fraction the_fraction( input);
  25.  
  26.             long double current_error;
  27.             int step_taken;
  28.             do
  29.             {
  30.                 step_taken = the_fraction.step();
  31.                 current_error = the_fraction.get_relerror();            
  32.                 cout << the_fraction << '\n';
  33.             } while( (current_error > error) && (step_taken != 0));
  34.         }
  35.     }
  36. }
  37.