Question: java program 2 Rational Implement a class to represent rational numbers. Each rational number consists of a numerator and a denominator, both of type int.

java program

java program 2 Rational Implement a class to represent rational numbers. Each

rational number consists of a numerator and a denominator, both of type

int. Since each rational number has its own numerator and denominator, these

2 Rational Implement a class to represent rational numbers. Each rational number consists of a numerator and a denominator, both of type int. Since each rational number has its own numerator and denominator, these must be instance variables. Furthermore, good object-oriented programming suggests that the visibility of the variables should be private. 3 Constructors The class Rational has two constructors. One of them has two formal parameters, which provide the initial values for both instance variables. The other constructor has a single parameter, which provides the initial value for the numerator: the denominator is assumed to be 1 4 getters Implement access methods that return the numerator and denominator of this rational, but no setter methods. An object that has no setter methods, and no other methods for

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!