PDA

View Full Version : Anybody here knows f.. java?!! Any master??


ultraman6970
12-05-2012, 10:50 PM
I been for the last 3 days figuring out a darn simple program for one of my classes and I cant get this crap right.

Simple stuff... methods... loop... and a if comparison (i even have the code done for this)

Have to do a calculation using a formula 3 times (loop), defined my main... entered the data and calculation in the same method and returning the final value for the formula to main.

After that I have to compare using if (that is the easiest way to do it) but i cant find the way to get the final value i got at each loop out of the loop and store it somewhere else for comparission, maybe im overthinking this?? maybe im wrong??

Any help will be appreciated.

monkeybanana86
12-05-2012, 10:54 PM
have you tried putting a new chain on it? if it skips then the teeth are definitely worn out! :)

ultraman6970
12-05-2012, 11:02 PM
Tried everything :) even campagnolo statements, they worked better than the shimano one tho :)

scottaharper
12-05-2012, 11:53 PM
Not 100% sure I understand what you are trying to do, but if I get the gist of it I would store the output of the formula in an array with the iterator of your loop as the index. Just be sure to instantiate your array outside the loop. Then you should be able to do whatever you want with it. Let me know if I misunderstood. I am pretty handy with java and would be glad to help.

Scott

jtakeda
12-06-2012, 12:11 AM
Not 100% sure I understand what you are trying to do, but if I get the gist of it I would store the output of the formula in an array with the iterator of your loop as the index. Just be sure to instantiate your array outside the loop. Then you should be able to do whatever you want with it. Let me know if I misunderstood. I am pretty handy with java and would be glad to help.

Scott

Scott is correct. Use an array.

ultraman6970
12-06-2012, 12:14 AM
Actually i got the thing working by mistake but still have some questions, programing it never being my forte! neither my head but either way... I'll send you the code so you could read it... is not beauty but have some questions, i really dont get why it worked... it shouldnt :/

ultraman6970
12-06-2012, 12:15 AM
Cant use array ... :D only method (the objective of the homework) mixed with a loop...

Scott is correct. Use an array.

ultraman6970
12-06-2012, 12:31 AM
Code sent.

R2D2
12-06-2012, 07:42 AM
Maybe time for a new major?
Said in jest.
But I will let you know that this a common problem with coding. It works and it shouldn't or it doesn't work but should.
Some times it takes days for the answer or understanding to suddenly appear.
The best method (not said in an object oriented context) is to explain in detail what you are trying to accomplish and half way through the explanation you go "Oh! I see it know."
I'll give you high marks for asking for help. You'd be suprised at how many in the software industry don't and flounder around.
A mature developer knows when to ask for aid.

boxerboxer
12-06-2012, 07:46 AM
This is an awfully funny place to ask this but if you put up te problem def and some code I can probably help.

ultraman6970
12-06-2012, 08:10 AM
Thanks guys, around 1am or so figure it out my problem, had a bad problem of misunderstood concept. 3 f... days but got it... im one of those guys that can't program period... never been able to do it right... :)

My friends were not answering emails so had nowhere else to go and since we have a little bit of everything in here... why not to ask? :D

:)

cp43
12-06-2012, 08:24 AM
One piece of general computer/programming advice that was in a book I had as a child.

"The computer will always do exactly what you tell it to, even if what you tell it to do is goofy."

So, when you're debugging, remember that the computer doesn't know what you want it to do, only what you've told it. So, you have to think about everything as, "What does this line tell the program to do?" rather than "What do I want this line to do?" It's a subtle difference, but very important.

Good luck.

Chris

boxerboxer
12-06-2012, 08:57 AM
One piece of general computer/programming advice that was in a book I had as a child.

"The computer will always do exactly what you tell it to, even if what you tell it to do is goofy."

So, when you're debugging, remember that the computer doesn't know what you want it to do, only what you've told it. So, you have to think about everything as, "What does this line tell the program to do?" rather than "What do I want this line to do?" It's a subtle difference, but very important.

Good luck.

Chris

I'll second this and add that when I'm debugging it's often helpful for me to take pencil and paper and step through my program, tracking the value of my variables and such as I go through and making sure that, say, a counter is reaching the value I think it should be.

thegunner
12-06-2012, 09:09 AM
also pm'd -- current java engineer/web developer :)

aaronv
12-06-2012, 09:37 AM
I have to wonder out loud if this is an intro class. If it is, I think that Java is a poor choice for teaching fundamentals. It pushes a lot of syntax for the type system up front before you can begin experimenting. The classic example is the amount of code required to open a file. Don't cast yourself as a 'one of those guys who can't program' until you have experimented with a couple of other languages.

thegunner
12-06-2012, 09:39 AM
I have to wonder out loud if this is an intro class. If it is, I think that Java is a poor choice for teaching fundamentals. It pushes a lot of syntax for the type system up front before you can begin experimenting. The classic example is the amount of code required to open a file. Don't cast yourself as a 'one of those guys who can't program' until you have experimented with a couple of other languages.

here's where i champion the readability of ruby! (and how i hate the whitespacing req of python...)

R2D2
12-06-2012, 10:45 AM
Assembler rules!!!!!!!!!

merlinmurph
12-06-2012, 11:54 AM
Assembler rules!!!!!!!!!

In the words of a co-worker, anything else is girlie code. :eek:

Said in jest - kinda....

Welcome to the wonderful world of programming.

Murph (who works with mainframe assembler, C, Perl, REXX, etc....)