Question: 2. (35 points + 5 bonus points) Implement an immutable data type Rational for rational numbers with the following API. public class Rational Creates a

 2. (35 points + 5 bonus points) Implement an immutable data
type Rational for rational numbers with the following API. public class Rational
Creates a rational number Rational(int numerator, int denominator) Rational plus (Rational that)
Rational minus (Rational that) Rational times (Rational that) Rational dividedBy (Rational that)

2. (35 points + 5 bonus points) Implement an immutable data type Rational for rational numbers with the following API. public class Rational Creates a rational number Rational(int numerator, int denominator) Rational plus (Rational that) Rational minus (Rational that) Rational times (Rational that) Rational dividedBy (Rational that) boolean equals (Rational that) String toString() sum of this rational number and that difference of this number and that product of this number and that quotient of this number and that is this number equal to that? string representation in this format: "a/b" Mathematical expressions for rational numbers: c d It lcm(b, d), Icm(b, d) a 2 Icm(b, d) aca.c bbid ba= public class Rational implements Comparable

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!