Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hi This is my data structure class assignment. I really try my best to solve this but it's too hard for me... Please help me

Hi

This is my data structure class assignment.

I really try my best to solve this but it's too hard for me...

Please help me to do this java problem.

Thank you so much

/**

* A class that represents a rational number.

*

* @author Charles Hoot

* @version 4.0

*/

public class Rational

{

// PUT PRIVATE DATA FIELDS HERE

/**

* The default constructor for objects of class Rational. Creates

the rational number 1.

*/

public Rational()

{

// ADD CODE TO THE CONSTRUCTOR

}

/**

* The alternate constructor for objects of class Rational. Creates

a rational number equivalent to n/d.

* @param n The numerator of the rational number.

* @param d The denominator of the rational number.

*/

public Rational(int n, int d)

{

// ADD CODE TO THE ALTERNATE CONSTRUCTOR

}

/**

* Get the value of the Numerator

*

* @return the value of the numerator

*/

public int getNumerator()

{

// CHANGE THE RETURN TO SOMETHING APPROPRIATE

return 0;

}

/**

* Get the value of the Denominator

*

* @return the value of the denominator

*/

public int getDenominator()

{

// CHANGE THE RETURN TO SOMETHING APPROPRIATE

return 0;

}

/**

* Negate a rational number r

*

* @return a new rational number that is negation of this number -r

*/

public Rational negate()

{

// CHANGE THE RETURN TO SOMETHING APPROPRIATE

return null;

}

/**

* Invert a rational number r

*

* @return a new rational number that is 1/r.

*/

public Rational invert()

{

// CHANGE THE RETURN TO SOMETHING APPROPRIATE

return null;

}

/**

* Add two rational numbers

*

* @param other the second argument of the add

* @return a new rational number that is the sum of this and the

other rational

*/

public Rational add(Rational other)

{

// ADD NEW CODE AND CHANGE THE RETURN TO SOMETHING APPROPRIATE

return null;

}

/**

* Subtract a rational number t from this one r

*

* @param other the second argument of subtract

* @return a new rational number that is r-t

*/

public Rational subtract(Rational other)

{

// CHANGE THE RETURN TO SOMETHING APPROPRIATE

return null;

}

/**

* Multiply two rational numbers

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_2

Step: 3

blur-text-image_3

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

Advanced MySQL 8 Discover The Full Potential Of MySQL And Ensure High Performance Of Your Database

Authors: Eric Vanier ,Birju Shah ,Tejaswi Malepati

1st Edition

1788834445, 978-1788834445

More Books

Students also viewed these Databases questions

Question

Is it possible to have a negative forward slip? Explain.

Answered: 1 week ago

Question

4. Identify the challenges facing todays organizations

Answered: 1 week ago