View the step-by-step solution to:

CSC224 Homework #4 due: see COL Part I : Modify the given Fraction class as follwing : keep the negative sign to the numerator (denominator always...

I need to know how to write a fraction class adding the last six methods listed and the modifications that are listed.
CSC224 Homework #4 due: see COL Part I : Modify the given Fraction class as follwing : keep the negative sign to the numerator (denominator always greater than zero) modify all the constructors such that there is no common factor between numerator and denominator. add one more constructor which takes three integer parameters: Fraction (int whole , int numerator , int denominator) adding following class (static) methods Fraction plus (Fraction f1, Fraction f2) // f1 + f2 Fraction minus (Fraction f1, Fraction f2) // f1 - f2 Fraction times (Fraction f1, Fraction f2) // f1 * f2 Fraction over (Fraction f1, Fraction f2) // f1 / f2 Fraction negate (Fraction f1) // -f1 Fraction invert (Fraction f1) // 1/f1 Fraction power (Fraction f,int n) // f n where n could be negative boolean less (Fraction f1, Fraction f2) // return true if f < f2 , false elsewise boolean greater (Fraction f1, Fraction f2) // return true if f > f2 , false elsewise boolean same (Fraction f1, Fraction f2) // return true if f == f2 , false elsewise boolean proper (Fraction f1) // return true if f1 is proper ; 1/2 is proper while 3/2 is not boolean isNegative(Fraction f) // return true if f is negative, false elsewise adding the following public instance method(s) boolean equals(Fraction other) // return true if this and other are equal as fraction. String properString() // returns the string format of the fraction number in proper format : e.g 3/2 ==> 1 1/2 Modify the following : every fraction number created must be in its simplest form, i.e. there is no common factor between numerator and denominator.( e.g. 1/2 instead of 2/4.) if the fraction is negative, keep denominator positive and numerator negative. improve toString() so that it produces a better looking string format of fraction: if denominator is 1 , then display the fraction as integer, in other words, 2/1 should be displayed as 2. make sure that string likes 1/-2 never happen ( it should produce -1/2 instead.) Part II : Implement the application that provides the user interface. Your interface should be able to handle the input of the following formats : whole number e.g. 123 numerator / denominator e.g. 123/456 (sign) integer_part numerator / denominator e.g. - 1 2/3 (negative 1 and two thirds) the sign can only go with the integer_part this case.
Background image of page 1
Warning : You must name the above methods exactly the same way they are listed as above. (I would also use my driver to test your Faction class which expects you to name those methods exactly as I listed above.) A sample test driver class file t2.class and Fraction class file: Fraction.class . To submit : Both the Fraction.java of part I and your driver of part II through COL
Background image of page 2

Recently Asked Questions

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

-

Educational Resources
  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question