Question: can u fix the code so the second string fraction being divided can also be a regular fraction like 3/4 it can only handle it
can u fix the code so the second string fraction being divided can also be a regular fraction like 3/4 it can only handle it if it was a mixed fraction like 1 3/4 as well as add a bubble sort with the specifications in the second picture. Its in java. The first picture is just instructions for the first project which is the dividing fraction.


public class Utility { public static int findGCD(int n, int m) { if (n % m == 0) { return m; } return findGCD(m, n % m); } }
public class Test { public static void main(String[] args) { Fraction g=new Fraction(2,8); Fraction f= new Fraction("1 3/4"); System.out.println("Orig="+f+","+g); Fraction[]quotient_remainder=Fraction.divFract(f,g); System.out.println("After="+f+","+g); System.out.println("Quotient & Remainder="+quotient_remainder[0]+","+ quotient_remainder[1]); } }
public class Fraction {
int num, den;
public Fraction(int num, int den) { this.num = num; this.den = den; }
public Fraction(String fract) { String[]number = fract.split(" "); int integral = Integer.parseInt(number[0]); String[] num_dun = number[1].split("/"); int num = Integer.parseInt(num_dun[0]); int den = Integer.parseInt(num_dun[1]); num = integral*den+num; this.num = num; this.den = den; } public static Fraction[] divFract(Fraction f, Fraction g) { int num_div = f.num * g.den; int den_div = f.den * g.num; int gcd = Utility.findGCD(num_div, den_div); num_div/=gcd; den_div/=gcd; f.num = num_div; f.den = den_div; int quotient = num_div/den_div; int remainder = num_div % den_div; Fraction[] retValue = {new Fraction(quotient, 1), new Fraction(remainder, 1)}; return retValue; } public String toString() { if(den==1) return num+""; else return num+"/"+den; }
}
S C Get Homework Help With C C Can U Fix The Code Sox + V E = 0 . https://www.chegg.com/homework help/questions and answers/u fix code second string fraction divided also regular fraction like 3 4 handle mixed frac 944562317?trackid=OFF 0 .. Please following the following instructions before turning in your USB 1. Your USB will have a label from outside under your LastName_FirstName 2. Inside your USB there is a FOLDER under the name: Your LastName_FirstName_P1. 3. Inside the above folder, a. There are only 2 or 3 files: Fraction.java and Test.java where the class Utility file can be added inside Fraction.java or to be in a separated file. There will be NO files with suffix class. b. The first line in each file must bear your full name after the double slashes // 4. Your Instructor will compile your files and run Test.class via cmd/terminal. Your must be responsible to make sure your files are standard to run properly. Your instructor WILL NOT touch your files. Your instructor will make his own Test file to evaluate all students performance. 5. Here is an example of the instructions (caller) in Test.jave: Fraction g new Fraction(2,8): Fraction fnew Fraction ("1 3/4"); System.out.println("Orig="+f+""+g); Fraction() quotient_remainder = Fraction divFractif, el: System.out.println("After +f+"." ); System.out.println("Quotient & Remainder +quotient_remanider[0] + ": - +quotient_remainder[1] ); 6:27 PM Type here to search M e s @ 2/14/2020 C Get Homework Help With C Can U Fix The Code Sox + E = 0 . https://www.chegg.com/homework help/questions and answers/u fix code second string fraction divided also regular fraction like 3 4 handle mixed frac 944562317?trackid=OFF 0 .. Program: Sort in Fraction, Due on Saturday Feb 15, 2020 30 points Piyush A. Indian Institute Of E... 359 Please following the following instructions before turning in your USB Find me a tutor 1. Your USB will have a label from outside under Your_lastName_First Name 2. Inside your USB there is a FOLDER under the name: YourLastName_FirstName_P2. 3. Inside the above folder, a. There are only the source codes. There will be NO files with suffix class. b. The first line in each file must bear your full name after the double slashes Il 4. Your instructor will compile your files and run Test.class via cmd/terminal. You must be responsible to make sure your files are standard to run properly. Your instructor WILL NOT touch your files. Your instructor will make his own Test file to evaluate all students' performance 5. Here is a sample of the instructions (caller) in Test.java: Strings 2,3/4, 1/16, 23/2, 22/4...15/2"://code to read from keyboard via Scanner s Utility.clean(s): System.out.println("CleanOrig-1" +S+"|"); 1/code to create an object of Sort SortSP objnew SortSpis: //SP are the initials of author System.out.println("init array of Fractions .obj); obj.bubbleSP: 1/ sort array using bubble, insertion, or selection System.out.println("Fractions in increasing order o bi: 6. Outline of class Sort5P a. Name of class is "Sort" followed by your initials in upper cases. b. There are 2 attributes: (Note: You should not add any extra attributes) String SP:/ame of string started with followed by your initial in upper cases. Fraction) aSP:/ame of array started with a followed by your initial in upper cases. c methods: resetSP: to set the second attribute to be its original, (not create any unnecessary new fractions). bubble SP: to sort the 2nd attribute in increasing order additional methods to make the sample work 7. Note: SP are the initials of your instructor. You need to replace they by yours. Type here to search 6:27 PM 2/14/2020 S C Get Homework Help With C C Can U Fix The Code Sox + V E .. = 0 . https://www.chegg.com/homework help/questions and answers/u fix code second string fraction divided also regular fraction like 3 4 handle mixed frac 944562317?trackid=OFF 0 Juuy TexLDOUK JOIULIONS Cxpert van luuy rack Practice JOTLIT Fraction pubic static Fractions divFract(Fraction int num_div .num .den; int den dlv = f.deng.num: performing simplyfication Int gcd Utility find GCD(num_ dlv, den_div): num_dlv/=ged; den_dlv/eged; f.num = num_div; f.den den_div; int quotient = num_div/den_div; Int remainder = num_div % den_div; Fraction retValue Inew Fractionquotient, 1. new Fraction(remainder, 1 return retValue: public String toString if den=1) return nume": else return num="/den Output
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
