Question
Can you add comments to this code please? import java.util.*; import java.io.File; public class Fraction_V1 { public static int gcf(int a, int b) { return
Can you add comments to this code please?
import java.util.*; import java.io.File;
public class Fraction_V1 { public static int gcf(int a, int b) { return b == 0 ? a : gcf(b, a % b); }
public static void main(String [] args) { HashMap
} } } catch (Exception e) {//throws exception if file not found System.out.println(e); }
for (int j = 0; j < i; j++) { String fract = fractions[j]; String []part = fract.split("/"); int nume = Integer.parseInt(part[0]); int denom = Integer.parseInt(part[1]);
int gecma = gcf(nume, denom); int num = nume/gecma; int dec = denom/gecma; String simplifiedFraction = Integer.toString(num) + "/" + Integer.toString(dec);
int count = fractionCount.get(simplifiedFraction); System.out.println(fract + " has a count of " + count);// returns fraction with the number of occurances } } }
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