Menu
Question Index
...


Write a program to get the Highest Common Factor (HCF) of fractions.

Input (Fraction Numbers) Output(Fraction Numbers)
{ {4 / 5}, {5 / 6}, {14 / 15} } 1 / 30
{ {3 / 13}, {6 / 7}, {18 / 7} } 3 / 91
{ {14 / 39}, {35 / 9}, {28 / 3}, {91 / 11} } 7 / 1287
{ {57 / 10}, {95 / 12}, {133 / 90} } 19 / 180
{17 / 47} 17 / 47

class HCFOfFractions

{    public static void main(String s[])
    {
        Fraction[] fractions = {new Fraction(4, 5), new Fraction(5, 6), new Fraction(14, 15)};
        System.out.println("The Highest Common Factor is : " + getHcf(fractions));

    }


public static Fraction getHcf(Fraction[] fractions) {
//Write a code here to get the HCF of fractions and return it. If required you can use getFactors, getLcm and getHcf methods.
}

public static int[] getFactors(int number) {
//Write a code here to get the factors of a given number and return it.
}

public static int getLcm(int[] number) {
//Write a code here to get the lcm of the given numbers.
}

public static int getHcf(int[] number) {
//Write a code here to get the hcf of the given numbers.
}
}
class Fraction {

int numerator;
int denominator;

public Fraction(int numerator, int denominator) {
this.numerator = numerator;
this.denominator = denominator;
}

@Override
public String toString() {
return numerator + "/" + denominator;
}
}

Doubts

Problems

Topic: Java Multiple Methods In One Class

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App