Question: Program: FracturedFraction implementation of the WackyFractionlnterface Develop a Java class called FracturedFraction that correctly implements the WackyFractionlnterface. Download a copy of this interface here-WackyFractioninterfacejava The

Program: FracturedFraction implementation of the WackyFractionlnterface Develop a Java class called FracturedFraction that correctly implements the WackyFractionlnterface. Download a copy of this interface here-WackyFractioninterfacejava 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, 1/2, 3/4, 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.

Program: FracturedFraction implementation of the WackyFractionlnterface Develop a Java class called FracturedFractionWrite this program in JAVA and compile it in JDK 11.

WackyFractionInterface.java is below

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. }

add: ba+dc=b+da+c subtract: badc=Min(b,d)(ac). Note: this is a correction. multiply: badc=bdac divide: badc=adbc getReciprocal(): returns the reciprocal, for example baab compareTo(WackyFractionInterface other) Upholds the standard contract of the ComparablecE> 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+ equals cb. - The format of the toString() should be simply "numerator/denominator". For example, 1/2

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!