Ah! Help a Java Noob
Ha I'm so pathetic when it comes to Java, looks like Czech to me :( Well, for a program I'm supposed to test a Fibonacci sequence betting strategy starting at the left of the series (1,1,2,3,5,8..ect). If I win, my bet amount increases by moving 1 up the series and if I lose, I move my betting amount back to the beginning of the series. How on earth am I supposed to store these Fibonacci series numbers (the first 10 or so) and much less test them?!
Any help is appreciated, seeing as my brain is about to explode =P
Welcome to the Java Forums Snejana.
I'm not quite sure I understand your betting strategy... for storing the Fibonacci series - where they are a known quantity, you could just use a standard array. For unknown quantities you might want to look at an ArrayList or some class in the API that adds values to the list as the program runs. Your second question is a little vague... what do you mean by "test"ing them? Do you have a test method? Are you testing the above strategy(which at the moment is still a little unclear)?
I think you would be well-served if you wrote some psuedocode for your program and/or strategy.
See you around :)
Thanks for the welcome =D! I'll take a look at arrays, though I'll probably have no idea what I'm doing haha. As for the second question, once I get the quantities stored I should have no problem figuring it out. Thanks a bunch!
No problem Snejana. Have you gotten yourself a good book yet? If so, which one? I always recommend Head First Java, by Kathy Sierra and Bert Bates, but there are a number of other great books too. Don't forget to utilize Sun's online tutorials.
I understand you're new, but I must remind you to review the FAQ section before posting. This isn't a problem at the moment, but please try to use more descriptive titles when posting a thread - this helps us to more efficiently help you. Experienced programmers might not be willing to view a "Noob needs help" thread when instead they might view a "Fibonacci sequence and storage testing" thread because they have experience with that sequence... etc. Something to consider.
When you get somewhere with your code, please - post back your results if you get stuck. We're here to help. And please remember to use code tags.
I'm having a little bit of trouble understanding what exactly you want. If you want to make a program that finds all Fibonacci numbers up to a certain point, you could do it several ways. I would do it by setting up 3 ints.
And then, you make a for loop that updates the numbers. See if you can figure it out (that is, if this was what you wanted haha).
int a = 0;
int b = 1;
int c = a+b;