Results 1 to 3 of 3
Thread: variable output is always 0
- 09-25-2009, 02:32 AM #1
Member
- Join Date
- Sep 2009
- Posts
- 2
- Rep Power
- 0
variable output is always 0
Hello all, new the forum. Looking to use this forum for advice/help in writing software for my CSC classes as I work on my software engineering degree.
Well i hit a speed bump and i cant figure out what going on. I had a to write a program will calculate the length of time to reach a final population or
final population after a given number of months with user input of the following fields: birth/death rates, initial Pop, population threshold.
whenever method numBunnies is called it will output 0 no matter the values being passed to it. the calculations are correct, and the program was working at one point, i havent changed anything.
whenever method numMonths is called will get stuck in an infinite loop. i believe this is because the outputing variable also always seems to equal 0 and thus not knowing when to exit the loop.
i'll attach the complete java file in txt format, maybe someone can see what im missing.
- 09-25-2009, 03:22 AM #2
Member
- Join Date
- Sep 2009
- Posts
- 2
- Rep Power
- 0
nvm, i figured it out
BunniesOld = IntPop / threshold;
in each method need to be cast to a double:
BunniesOld = (double)IntPop / threshold;
- 09-25-2009, 06:26 AM #3
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
If you've solve the problem, please mark the thread solved.
Similar Threads
-
Can anyone tell me how this output?
By vysh in forum Advanced JavaReplies: 16Last Post: 05-10-2009, 08:32 PM -
Java, output string, getting correct output? HELP!
By computerboyo in forum New To JavaReplies: 2Last Post: 02-25-2009, 11:44 PM -
what the outPut
By alksam in forum Advanced JavaReplies: 5Last Post: 12-25-2008, 01:44 PM -
What will be output and why
By huma in forum Threads and SynchronizationReplies: 4Last Post: 06-26-2008, 10:14 PM -
output
By Camden in forum New To JavaReplies: 3Last Post: 12-01-2007, 10:34 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks