// Add this rational number to another fraction. // note: not simplified public Fraction add(Fraction other) throws Exception { Fraction ans = new Fraction( (this.num.multiply(other.denom).add(this.denom.multiply(other.num))), this.denom.multiply(other.denom)); return ans.simplify(); } // add(fraction)
// multiplies this and another fraction public Fraction multiply(Fraction mult) throws Exception { Fraction ans = new Fraction(this.num.multiply(mult.num), this.denom.multiply(mult.denom)); return ans.simplify(); } // multiply(int)