Question: Create java class named Fraction. This class is used to represent a ratio of two integers. Include mutator methods that allow the user to set
Create java class named Fraction. This class is used to represent a ratio of two integers. Include mutator methods that allow the user to set the numerator and the denominator. The output should be displayed as a ration, i.e. (5/9) style. The fraction class should contain the following: Private instance variables to store the numerator, denominator, and the ratio_value. Constructor(s) that set all of the instance variables. Public methods to get and set the instance variables. A public method named reduce() that returns lowest terms of a fraction. A public method named to String() that returns a String containing the traction as a ratio (x/y). Create a test program that allows the user to create array of 7 fractions, Then the program will sort the fraction in ascending order. The highest and the lowest fractions are thrown away and the remaining fractions are added together. The program should display all the fractions and their sum. The sum should be reduced to lowest terms and displayed on the screen. For example, if the sum is 20/60, the program should displau 1/3. Write a sort method in the test program to sort the array of fractions and calculate the sum. You need turn in the source code and screen shot of the output. You may be asked to give a demonstrate of your running application. No credit will be given if the program doesn't compile successfully. The due date has to met; otherwise the program will not be acccpted. Assume you have the following 7 fractions: 6/7, 2/4, 3/4, 3/18m 1/8, 10/8, 10/20, 2/6, then the output after throwing away the lowest (1/8) and the largest (6/7) fractions, will be: 3/18 + 2/6 + 2/4 + 10/20 + 3/4 = 9/4 Please submit your code and your output
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
