Hello to All, I've would like to see if this coding runs the Ackerman function. I'm not understanding why I keep getting this error. Sure it is just a beginner's mistake. I've run many other math class projects, this one has me scratching my head. Blessings, Chetanji
On your way in you may have missed that we have a policy on screen names here at JavaRanch. Basically, it must consist of a first name, a space, and a last name, and not be obviously fictitious. Since yours does not conform with it, please take a moment to change it, which you can do right here.
As to your question, the method must return a result for all branches of execution. As it is, there are some branches that would reach the end of the method without having encountered a "return" statement. Thus, there would not be a result to return; this is not allowed. One case would be if m < 0. You might want to return something indicating an error in those cases (like a -1).
Ping & DNS - updated with new look and Ping home screen widget
Joined: Dec 01, 2007
Thanks for setting me straight on the Name Display. That was the name all my friends call me where I work and at home.
I thought I had closed up all the holes in the program, but obviously not. Here is what I added at the top of the program and I still get the same error message. What am I missing?
You get this error because there is a possibility that the execution gets at a spot where there the method ends but there is no "return" statement. Since you specified that the method returns int, there must be a "return" statement at all possible execution paths where the method ends.
Look at the third if-statement: if ((m > 0) && (n > 0))
That one has no else-statement. If the condition is false, then you get to a point where you're not returning a value.