Question: Question 2 (60 Points) Carefully study the provided BigRational class (Unzip the given file and you will find a Netbeans project). If you find any

Question 2 (60 Points) Carefully study the provided BigRational class (Unzip the given file and you will find a Netbeans project). If you find any logic errors, fix them and list them as comments at the top of the corresponding source file (You may not find any!).

Do the following modifications to the BigRational class. Make sure to throw appropriate exceptions.

1. BigRational pow( int exp ) // exception if exp < 0

2. BigRational reciprocal( )

3. BigInteger toBigInteger( ) // exception if denominator is not 1

4. int toInteger( ) // exception if denominator is not 1

5. Modify the BigRational class so that 0/0 is legal and as interpreted as indeterminate by toString.

6. Implement Comparable interface for BigRational class. Store 1 / 3, 1 / 5, 1 / 8, 2 / 8, 3 / 8 as BigRational in an ArrayList. Now use the stock generic algorithm, sort from Collections clsss to sort the content. Print the final array list and show that it was actually sorted.

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!