Hi, so my problem is that I need a method that does the calculation for my program and return it. Here's what I have so far. It keeps saying that the method needs to return a double value. Can someone help me? Thanks in advance.

private double spoonConvert (double answer)
    {
        if (unit == 1 && unit2 == 2)
            return (amount / 3);

        else if (unit == 1 && unit2 == 3)
            return (amount / 48);
        
    }

unit, unit2 and amount are declared somewhere in my program.
What I want is that it only return a certain equation when the user input a certain value.

You need to have a guaranteed return value. Currently all of your returns are dependent on one of the if() clauses being true. If none of them end up true, there is no final return.

If you put a default return at the end of the method, you will make the compiler happy that all of the cases are covered.

Oh yay! Thanks a lot.

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.