

public class xTestRational
{  public static void main (String[] args)
   {// create and initialize some xRational numbers
	 // Note that every declaration of an xRational can only occur within
	 // a "try" clasue with a corresponding "catch" or "throw"

	 try {
	      xRational r1 = new xRational (-4, -8);
	      xRational r2 = new xRational (16, -256);
	     System.out.println (r1.show() + 
				   " ++ " + r2.show() + 
				   " = " + (r1.add(r2)).show());
	     System.out.println (r1.show() + 
				   " -- " + r2.show() + 
				   " = " + (r1.sub(r2)).show());
	     System.out.println (r1.show() + 
				   " ** " + r2.show() + 
				   " = " + (r1.mult(r2)).show());
	     System.out.println (r1.show() + 
				   " // " + r2.show() + 
				   " = " + (r1.div(r2)).show());
	     System.out.println (r1.show() + 
				   " << " + r2.show() + 
				   " = " + (r1.lessthan(r2)));
	 } catch (Exception d) {System.out.println (d);}

	 // try to divide 0 by 0

	 try {
	      xRational r4 = new xRational (0, 1);

	      System.out.println (r4.show() + 
				   " // " + r4.show() + 
				   " = " + (r4.div(r4)).show());
	 } catch (Exception e) { System.out.println (e);}

	 // Try denominator of 0

	 try { xRational r0 = new xRational (1, 0);} 
	 catch (Exception e) {System.out.println (e);}
   }
}






