I'm working on a program where the monkey climbs a tree.
10 feet takes 10 minutes. he falls back 3 and rests for 10 minutes.
the code I have written I thought worked when I traced it on paper, but returns stack overflow when I run the program.
*edit - ok so somehow i no longer get a stack overflow, but i don't get the result i need. it prints 30 regardless of the poleHeight. Ive tried tracing it but i don't see where Im making a mistake.
for poleHeight= 18;
static double climbTime(double poleHeight){
double time = 0.0;
double t = 10.0;
double climbed = 7.0;
//base case
if(poleHeight <= 10.0){
time = poleHeight;
}
else{
poleHeight = poleHeight - climbed;
t = t + 10.0;
climbTime(poleHeight);
}
return (time + t + 10.0);
}