Question: a) Design and implement a Comparable Java class to represent a Rational number such as 3/2. Your class will have the following methods as

a) Design and implement a Comparable Java class to represent a Rational number such as 3/2. Your class will

a) Design and implement a Comparable Java class to represent a Rational number such as 3/2. Your class will have the following methods as well as any other methods necessary (setters, getters, etc.). A constructor that takes all parameters (numerator, denominator), A function that returns the number of existing Rational objects, Override the toString method, Methods for adding and multiplying Rational objects, Your methods will throw exceptions if there are problems. b) Write another class to test your Rational class including the exceptions.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Here is the implementation of the Rational class in Java java import javautilArrayList import javautilList public class Rational implements Comparable ... View full answer

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 Programming Questions!