Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

If Loop Counting

807600Oct 29 2007 — edited Oct 30 2007
Hi Everyone,
I'm just starting out on Java, and i've got stuck in one of my programs. Basically I'm trying to create a loop that counts the number of instances a candidate passes different exams. I've been playing with it to try and make some progress but all I have at the moment is:
  public int getCountPassMarks()
    {
        int passCount = 1;
        do
        { 
 
            if (examMarks.readInt() >= 40) passCount++;
            if (examMarks.finished()) dataFinished = true;
        }
        while (!dataFinished);
        return passCount;
    }
What i'm intending for it to do is every time it reads a mark that is greater that 40 it adds 1 to my counter variable, and then I can return the variable at the end to give the value, but I just can't get it to work. Any ideas?

Thanks for the help!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 27 2007
Added on Oct 29 2007
14 comments
139 views