Question
In JAVA . Write a class for a Fraction. This class will hold the numerator and denominator of a fraction. Each time you write a
In JAVA . Write a class for a Fraction. This class will hold the numerator and denominator of a fraction. Each time you write a method, test that method in the Driver Class (So this program need to have two classes, the Fraction class and the driver class).. Add two fractions returning the sum in lowest terms, susbtract the two fractions returning the difference in lowest terms. multiply the two fractions and divide the two fractions , and finally compare the two fractions and determine and return the decimal value of the fraction. Include a static method to generate and return a random fraction that is between 0 and 1. A toString() method that returns a string in form of a/b .Here is a simple way to find the greatest common divisor of two numbers: start with the smaller of the two numbers and determine if the number goes into the larger of the two numbers evenly, if it does, this is the greatest commonn divisor, if not, repeately substract 1 from the value of the smallest number until you find a value that goes into both number evenly.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started