Menu
Question Index
...


Write a program to get the Least Common Multiple (LCM) of fractions.

Input (Fraction Numbers) Output(Fraction Numbers)
{ {4 / 3}, {5 / 6}, {14 / 9} } 140 / 3
{ {39 / 14}, {9 / 35}, {3 / 28}, {11 / 91 } 1287 / 7
{ {3 / 10}, {5 / 6}, {9 / 14}, {7 / 22}, {11 / 26}, {13 / 34} } 45045 / 2
{ {8 / 65}, {10 / 91}} 40 / 13
{17 / 47} 17 / 47

class LCMOfFractions

{    public static void main(String s[])
    {
        Fraction[] fractions = {new Fraction(4, 3), new Fraction(5, 6), new Fraction(14, 9)};
        System.out.println("The Least Common Multiple is : " + getLCM(fractions));

    }


public static Fraction getLCM(Fraction[] fractions) {
//Write a code here to get the LCM 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