Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java coding please follow the following instruction Designing a Java class: A rational number is the quotient of two integers - the numerator (at the

Java coding please follow the following instruction

Designing a Java class: A rational number is the quotient of two integers - the numerator (at the top) and denominator (at the bottom). The denominator cannot be zero. Two rational numbers can be added, subtracted, multiplied and divided (I hope I dont have to tell you how). Write a java class Rational for a rational number with the following specs: A constructor that gets two integers (make sure the denominator is not 0). The numerator and denominator should be private. Getters: public int getNumerator() and public int getDenominator() Setters: public void setNumerator(int n) and public void setDenominator(int d) Public methods public Rational add(Rational r1), public Rational subtract(Rational r1), public Rational multiply(Rational r1) and public Rational divide(Rational r1). Printer function: public void print(). The number should be printed in the format n/d (numerator, forward-slash, denominator).

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

MySQL/PHP Database Applications

Authors: Brad Bulger, Jay Greenspan, David Wall

2nd Edition

ISBN: 0764549634, 9780764549632

More Books

Students also viewed these Databases questions

Question

Organizing Your Speech Points

Answered: 1 week ago