Question: 1 -(Code only) Write a class called Fraction, which can be used to store an exact fraction. It must haves - A field to store

 1 -(Code only) Write a class called Fraction, which can be

1 -(Code only) Write a class called Fraction, which can be used to store an exact fraction. It must haves - A field to store the numerator - A field to store the denominator A toString method that returns a neatly formatted String representing the fraction An equals method that compares itself to another Fraction - An add method that adds itself to another Fraction and returns a new Fraction Appropriate constructor and accessors as needed Write a program that asks the user to enter the numerators and denominators of two fractions and create corresponding Fraction objects. Check for valid input and a O denominator. Then output both Fractions (using your toString method implicitly), whether they are equal, and their sum. Note: You do not need to reduce your answer for the equals and sum. Name your main class Hw5pr1 and your file Hw5pr1.java. Submit all java files

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!