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.

Results 1 to 3 of 3

Thread: need this program written

  1. #1
    Junior Member
    Join Date
    May 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default need this program written

    i have a set of answers to a test. i need to have a program calculate students answers against the answers. each correct answer is 2 points, each wrong anser is - 1 point, and no answer gets 0 points. the output needs to return the student ID, then the answers, next should be the test score, and last should be the test grade. grading scale of A thru F.i use netbeans to do this program. the ansers are true and false. T F F T F F T T T T F F T F T F T F T T. the first students ID and answers are ABC54301 T F T F T F T T T F T F T F F T T F T. the blank means he did not answer that question. please let me know what you think.
    Majic


  2. #2
    Junior Member
    Join Date
    May 2010
    Location
    India
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: need this program written

    Use toCharArray() method on the 2 Strings.
    Then use for loop and compare the Student's answer against actual answer.

    score = 0;
    for(i=0;i<actual.length;i++){

    if(student[i] == ' ') { /* do nothing, score is unaffected.*/ }
    else if(student[i] == actual[i]) { score += 2; }
    else { score -= 1; }
    }

    Then output in the format you want.

  3. #3
    Moderators helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,896
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: need this program written

    ::frown:: we try not to do other people's assignments for them, otherwise they will not learn the material assigned.

    We will answer any questions they have if they are intuitive and show that they have given some effort to solving the problem.