Reference no: EM13166163
Write a class called RationalNumber that represents a fraction with an integer numerator and denominator. A RationalNumber object should hvae the following methods:
public RationalNumber(int numerator, int denominator)
Constructs a new rational number to represent the ratio(numerator/denominator). The denominator cannot be 0, so throw an IllegalArgumentException if 0 is passed.
Public RationalNumber()
Constructs a new rational number to represent the ratio (0/1).
Public int getDenominator()
Return this rational number's denominator value; for examples, if the ratio is (3/5), returns 5.
public int getNumerator()
Returns this rational number's numerator value, for example, if the ratio is (3/5), return 3.
public String toString()
return a String representation of this rational number, such as "3/5". You may wish to omit denominators of 1, reuturning "4" instead of "4/1".