Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS forum!

Daniel Brackett

Greenhorn
+ Follow
since Dec 09, 2011
Daniel likes ...
Python Ubuntu
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
2
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Daniel Brackett

Ok so It's over.
Here is the solutions both in Recursive and For Loop variants.
Why recursive? because practice makes me better and I have only been at programming for about 9 months now. Thinking about different solutions to problems is good practice to understanding how the problem could be resolved.



and

9 years ago

Michael Krimgen wrote:by the way, is it an exercise to practise recursion?

Otherwise, I believe that a single for-loop would do the job and the code would be easier to understand an debug. :-)

Cheers,
Michael



OK I need to review for loops before I do that. I started with recursion because it seemed right.

I would like to be able to do it recursively as-well I guess that I'll set up two different methods to do the same thing. good practice for next year.

Still havin' a rough go at it here's what doing recently.
9 years ago
[quote=Greg Brannon
It's probably a stack overflow due to a recursive method that calls itself so many times that the stack overflows. Check the exit path of your recursive algorithm to see why it might not be executing.

How does one check the exit path? what is the exit path?

I just want the output on the console. This is possible no?

So I could just rewrite it as a for loop Yes?
9 years ago
Hi all,

I am lacking understand as to why I am getting this error message
at Euler1.divideBy5(Euler1.java:23)
at Euler1.divideBy5(Euler1.java:23)
at Euler1.divideBy5(Euler1.java:23)
at Euler1.divideBy5(Euler1.java:23)
at Euler1.divideBy5(Euler1.java:23)
at Euler1.divideBy5(Euler1.java:23)

I get the message about 1000 times any ideas?


Here's the Tester class
9 years ago
import java.util.*;

public class TempChecker3
{
private int cm;
private double max_temp;


Scanner s = new Scanner(System.in);
//read 12 values
public void highMonth()
}
double max_temp;
for (int cm = 0; cm < 12; cm++)
{
double temp = s.nextDouble();
if (cm == 0)
{
max_temp = temp;
max_month = cm;
}
else if (temp > max_temp)
{
max_temp = temp;
max_month = cm;
}

}
}
}
9 years ago
Hi

I am looking for help on a school project where I have to compare 12 average monthly temperatures and return the month with the hottest temp. How's the code looking is it going to be able do what I asked of it? Do I need to create a new MonthTemp Object in my tester class(not included) each time a enter a new value? PS I cannot use arrays.


9 years ago
Thank you Bear Bibeault! Success! and yes I was talking about method chaining!
9 years ago
Hi I am trying to return the value SavingsAcc in this coding exercise. I want to do this so that I can put together multiple methods in a single line. What do I need to do to fix it?

Here is the code;


here is the error:



SavingsAcc2.java:29: missing return value
return;
^
SavingsAcc2.java:35: missing return value
return;
^
SavingsAcc2.java:41: missing return value
return;
^
3 errors


I am doing all of this from the command line I plan on using eclipse or DR java soon but I just don't know them yet.

9 years ago