So here's my code. I had to do 3 constructor and 2 division methods. I have finished the 3 constructors. My question is on the division, where :(1) I have to divide a fraction by an integer and return, (2)divide an integer by a fraction and return.

public class IFraction extends Fraction {

    public IFraction(int I) throws DivideByZero {
        super (I,1);
}


public IFraction(Int x, Int y) throws DivideByZero
{
    super(x, y)
}

public IFraction(Int q) throws DivideByZero
{
    super(q)
}


public static IFraction Division(int L, Fraction R) throws DivideByZero
{
    if(L == 0) throw new DivideByZero();
    IFraction Answer = new IFraction(L * R.Numerator(),
        L.Denominator() 
    return Answer; 
}

public static IFraction Division(Fraction L, Int R) throws DivideByZero
{
    if(L.Numerator() ==0) throw new DivideByZero();
        IFraction Answer = new IFraction(L.Numerator() * R 


    };
};

That's my attempt on the divide, but it's wrong of course. Just need help on that part. Appreciate any help!

What problems are you having?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.