ythtyhyt
Welcome to the Java Programming Forums
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.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
ythtyhyt
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 ==
So basically i'm screwed : ( . Can't believe i've been doing this thing since 11am and it's now 3.30am =/
No, that's not what I was saying at all.
If you have any other more specific questions feel free to ask
atm i've got and thanks, appreciated.
public static void computeResult(String results, int[] examMarks, int[] cwMarks) { int count = 0; int count2 = 0; int count3 = 0; for (int l = 0; l >= 5; l++) { if (cwMarks[l] < 35 || examMarks[l] < 35){ count = count + 1; results= "You Failed!"; } else if (cwMarks[l] < 35 || examMarks[l] < 35){ count2 = count2 + 1; results="You passed by compensation!"; } else if (cwMarks[l] < 35 || examMarks[l] <35){ count3 = count3 + 1; results="You passed year 1!"; } }
So is this solution working or are you still having issues?
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.. =/
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.