Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 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
Step: 1
Here is the implementation of the Rational class in Java java import javautilArrayList import javautilList public class Rational implements Comparable ...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started