public class RationalNumber { private int numerator=0; private int denominator=1; public RationalNumber(int numerator,int denominator) { this.numerator=numerator; this.denominator=denominator; boolean g=true; if(denominator==0) { //System.out.println("Denominator must be >0"); return g; } else if(numerator==0) { numerator=0; return numerator; } int gcd = gcd(numerator,denomerator); this.numberator=numberator/gcd; this.denomerator=denomerator/gcd; if(denomerator<0) { denomerator *=-1; numberator*=-1; } } public static int gcd(int numerator,int denominator) { if(numerator==0||denominator==0) { return-1;//error code public int getNumerator; { return numerator; } public int getDenominator; { return denominator; }

This post has been edited by **modi123_1**: 14 September 2013 - 01:50 PM

Reason for edit:: please use code tags