Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

3.2.Utility methods You have to implement the following utility methods: Rational plus (Rational b): returns a rational number that is the addition of this number

3.2.Utility methods You have to implement the following utility methods:

Rational plus (Rational b): returns a rational number that is the addition of this number and b.

Rational times (Rational b): returns a rational number that is the multiplication of this number and b.

Rational divides (Rational b): returns a rational number that is the division of this number and b.

String toString(): returns the string representation of a rational number as num / den. If den is equal to 1, to String should return num.

equals (Rational b): returns true if this rational number is equal to b. Two rational numbers are equal if their numerators are equal and their denominators are equal. Note that both numbers have to be in their reduced form.

Int gcd (int num1, int num 2): it is a helper method that returns the gcd of two numbers. You may use Euclids algorithm. You should not change the signature of the methods (i.e. name, return type, access modifier and parameters).

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Pro SQL Server Wait Statistics

Authors: Enrico Van De Laar

1st Edition

1484211391, 9781484211397

Students also viewed these Databases questions