Question: Note: When you turn in an assignment to be graded in this class, you are making the claim that you neither gave nor received assistance

Note: When you turn in an assignment to be graded in this class, you are making the claim that you neither gave nor received assistance on the work you turned in (except, of course, assistance from the instructor or teaching assistants).

Program: FracturedFraction implementation of the WackyFractionInterface

Develop a Java class called FracturedFraction that correctly implements the WackyFractionInterface. Download a copy of this interface here - WackyFractionInterface.java Download WackyFractionInterface.java

The WackyFractionInterface that models a fractional number as a numerator divided by a denominator. This fractional number can be represented as the quotient of two integers. For example, , , and so forth are all rational numbers (in this case, we mean the mathematical meaning of the fraction, not the integer division this expression would produce in a Java program.) Your class will represent rational numbers as two values of type int, one for the numerator, and one for the denominator.

Your class should have two instance variables of type int. An additional constraint of a WackyFraction is that a numerator or denominator must be a positive, non-zero integer. In order to uphold encapsulation, your FracturedFraction class must uphold this restriction.

Include two constructors to your FracturedFraction class one that accepts two integers as arguments and a second no-arg constructor. The no-argument constructor should set both of the instance variables to 1. Here are the method headers for your constructors:

public FracturedFraction(int numerator, int denominator)

public FracturedFraction()

The semantics of the methods in the interface are specified in this document. Each of these methods must accept a WackyFractionInterface object as the single parameter. If you have any questions on the specification, please ask for clarification on the Discussion Board forum in Canvas.

add: ab+cd=a+cb+d

subtract: abcd=|(ac)|Min(b,d). Note: this is a correction.

multiply: abcd=acbd

divide: abcd=bcad

getReciprocal(): returns the reciprocal, for example abba

compareTo(WackyFractionInterface other) Upholds the standard contract of the Comparable interface in Java; Compares this fraction to another fraction to determine which one is larger, or if they are equal, without changing either one

The methods equals and toString() are defined in and inherited from Object. They should be overridden in any class that implements this interface following the standard contract for these methods as defined in the Object class.

Hint: Two fractional numbers a/b and c/d are equal if a*d equals c*b.

The format of the toString() should be simply numerator/denominator. For example, 1/2.

Write this program in JAVA and compile it in JDK 11. Be aware that Gradescope uses JDK version 11, so features in more recent releases may not work in Gradescope.

Make sure your program is well documented - including the comment block header at the top of your file with your name, date, the course number and section.

Upload the project source code file to Gradescope.

package cmsc256; /** This interface describes the operations of a wacky fraction. Forget all those boring rules of mathematics, we're going wacky WackyFractions have a numerator, denominator, and a sign. */ public interface WackyFractionInterface extends Comparable{ /** Sets this fraction to a given value. @param newNumerator The integer numerator. @param newDenominator The integer denominator. */ public void setFraction(int newNumerator, int newDenominator); /** Sets this fraction to a whole number. @param wholeInteger The integer numerator. */ public void setFraction(int wholeInteger); /** Gets this fraction's numerator. @return The fraction's numerator. */ public int getNumerator(); /** Gets this fraction's denominator. @return The fraction's denominator. */ public int getDenominator(); /** Sets this fraction's numerator.*/ public void setNumerator(int numerator); /** Sets this fraction's denominator.*/ public void setDenominator(int denominator); /** Performs a wackysum on this fraction and the given fraction without changing either one. @param operand A fraction that is the wacky sum of the first and second operands @return The wackysum of the two fractions. */ public WackyFractionInterface add(final WackyFractionInterface operand); /** Performs a wackydifference on this fraction and the given fraction without changing either one. @param operand A fraction that is the wackydifference of the arguments. @return The wackydifference of the two fractions. */ public WackyFractionInterface subtract(final WackyFractionInterface operand); /** Performs a wackyproduct on this fraction and the parameter fraction without changing either one. @param operand A fraction that is the wackyproduct of the arguments multiplication. @return The wackyproduct of the two fractions. */ public WackyFractionInterface multiply(final WackyFractionInterface operand); /** Performs a wackyquotient of this fraction and the parameter fraction without changing either one. @param operand A fraction that is the wackyquotient of the arguments. @return The wackyquotient of the two fractions. */ public WackyFractionInterface divide(final WackyFractionInterface operand); /** Gets this fraction's reciprocal. @return The reciprocal of the fraction. */ public WackyFractionInterface getReciprocal(); /** Compares this fraction to another fraction to determine which one is larger, or if they are equal, without changing either one. @param other The other fraction we are comparing to this fraction. @return An integer representing how the fractions compare. */ public int compareTo(final WackyFractionInterface other); // The methods equals and toString are defined in and inherited from Object. // They should be overridden in any class that implements this interface. } 

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!