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 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
Get step-by-step solutions from verified subject matter experts
