Question: HERE IS THE FOLLOWING TASK INSTRUCTIONS TO MAKE THE CODE DOWN BELOW: Part One Create a new class called Fraction.java. Include the following: Data Fields:
HERE IS THE FOLLOWING TASK INSTRUCTIONS TO MAKE THE CODE DOWN BELOW:
Part One
Create a new class called Fraction.java. Include the following:
Data Fields:
numerator (integer)
denominator (integer)
Constructor:
Custom constructor that expects both a numerator and denominator
Methods:
Getter for numerator
Getter for denominator
Method to add (expects one Fraction object, returns a new Fraction object)
((n1) / (d1)) + ((n2) / (d2)) = ((n1d2) + (n2d1)) / d1d2
Method to subtract (expects one Fraction object, returns a new Fraction object)
((n1) / (d1)) - ((n2) / (d2)) = ((n1d2) - (n2d1)) / d1d2
Method to multiply (expects one Fraction object, returns a new Fraction object)
(n1) / (d1) * (n2) / (d2) = (n1n2) / (d1d2)
Method to divide (expects one Fraction object, returns a new Fraction object)
((n1) / (d1)) / ((n2) / (d2)) = (n1d2) / (d1n2)
A toString() method that returns the fraction in
Part Two
Write a driver that creates Fraction objects and tests all methods specified above.
Can someone please help me write a code in basic, beginner JAVA using repl.it?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
