Implement immutable data type rational for rational number, Mathematics

Assignment Help:

Implement an immutable data type Rational for rational numbers that supports addition, subtraction, multiplication and division.

public class Rational


Rational(int numerator, int denominator)

Rational

plus(Rational b)

sum of this number and b

Rational

minus(Rational b)

difference of this number and b

Rational

times(Rational b)

product of this number and b

Rational

divides(Rational b)

quotient of this number and b

boolean

equals(Rational that)

is this number equal to that?

String

toString()

string representation

Notes

  1. You do not have to worry about testing for overflow, but use as instance variables two long values that represent the numerator and denominator to limit the possibility of overflow.
  2. Use Euclid's algorithm to ensure that the numerator and denominator never have any common factors.
  3. Include a test client that exercises all of your methods.

 

 


Related Discussions:- Implement immutable data type rational for rational number

School mathematics, I am interested in school mathematics online assignment...

I am interested in school mathematics online assignments , homework help, projects etc. I have good knowledge of mathematics and experience of 15+ years teaching mathematics in cen

Differentiation of a formula with two variables, I would like to calculate ...

I would like to calculate the high point of a mathematical formula with two unknown variables. At the same time I made the 1st derivation of the function. How can I best program th

Series solutions to differential equation, Before we find into finding seri...

Before we find into finding series solutions to differential equations we require determining when we can get series solutions to differential equations. Therefore, let's start wit

Problem solving for andre, Problem solving for andre A can of powdered ...

Problem solving for andre A can of powdered milk and a can of evaporated milk cost Php 83.90 together. Two cans of evaporated milk and a can of powdered milk cost Php 118.05

How much does every person required to pay rob, Rob purchased picnic food f...

Rob purchased picnic food for $33.20 to share along with three of his friends. They plan to split the cost evenly among the four friends. How much does every person required to pay

Consumer behaviour.., consumer behaviour in my feild of studies accounting ...

consumer behaviour in my feild of studies accounting ..

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd