The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

Re: Struggling with Java counter

Well from what you have given the problem is still a little unclear, but looking at your computeResult method I can see a few things that might be throwing it off

Your for loop is told to loop while l is greater than or equal to 5, which will never happen since you initialize it to 0

Also, you are using results => 34, which is not valid java code. results is an array of integers and as such does not directly evaluate to an integer. The => symbol is also incorrect.
This same issue is found when comparing results == "Compensation fail".

On a side note, when comparing to a string, you must use the .equals() method rather than the primitive ==

Re: Struggling with Java counter

i

--- Update ---

I'm still having issues. For this method my aim is :

"A method computeResult that, an array of student exam and coursework marks, returns a Stage Result for that student (again you may pass 2 arrays rather than one if you prefer). You may assume each module is weighted equally which is true for Stages 1 and 2 modules."

It basically ignores method 2 and just runs method 1. Technically it doesn't ignore it because if i put system.out.println("fwefewfewfewF"); in method 2 it'd show up. But i mean with the information i'm using atm it's just having no effect. I know the numbers aren't accurate atm for the if statement i've created but i just want to get it actually functioning for now. Sorry if my wording is terrible, i've been doing this for around 15-17 hours straight.. =/

Re: Struggling with Java counter

Well as I mentioned in the first reply, your for statement never runs the way you have it setup.
The logic behind it is saying to loop while your counter variable l is greater than or equal to 5. Since you start this variable at 0, which is not greater than or equal to 5, it never runs.