double compute()
{
double monthly, acumulation;
for(int y = 1; y<5; y++)
{
monthly = (Cost * numYears) / residual;
acumulation = (monthly * y);
return acumulation;
}
}

this is function i wrote to compute monthyly depreiation and accumulation. but the error i get is missing return statemen and i dont really get where that is coming from

The compiler isn't smart enough to confirm that your for loop will always be executed, so the return inside it will always be executed. If the values were such that the for loop ran zero times you would drop through to line 9 and get to the end of the method without encountering a return statement.

Do you really want to return on the very first iteration of your for loop? (I think not!)

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.