// Program demonstrating the use of a simple rational-number class
#include <iostream.h>
#include "rational3.h"

int main(void)
{ Rational z;                    /* by default, z is zero */
  Rational i(4);                 /* simple integer initialization for 4/1 */
  Rational r(3, 5);              /* rational number 3/5 */

  /* printing of initialized rational numbers */
  cout << "The following rational numbers have been defined" << endl;
  cout << "  z             i(4)         r(3, 5)" << endl;
  cout << z << "          " << i << "          " << r << endl;
  cout.setf(ios::fixed);
  cout.precision(5);
  cout << "The corresponding decimal values are:" << endl;
  cout << z.eval() << "       " << i.eval() << "        " << r.eval() << endl;

  /* using cin to read operation */
  cout << "Enter two fractions (a and b):  ";
  Rational a, b;
  cin >> a >> b;

  /* using the addition operation */
  Rational s = a + b;

  /* more printing */
  cout << "Two additional rational numbers are:" << endl;
  cout << "Your a        Your b        s = a + b" << endl;
  cout << a << "          " << b << "         " << s << endl << endl;
  return 0;
}
