Pls , I need help with this code


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Pls , I need help with this code

  1. #1
    Join Date
    Apr 2006
    Posts
    2

    Question Pls , I need help with this code

    the purpose to read from file and compare the data for each student with the first line in the file using arrays
    the text file contain --
    TTFTFTTTFTFTFFTTFTTF // this line the correct answer
    ABC54102 T FTFTFTTTFTTFTTF TF // first col is the student id and next is the student answer
    DEF56278 TTFTFTTTFTFTFFTTFTTF
    ABC42366 TTFTFTTTFTFTFFTTF
    ABC42586 TTTTFTTT TFTFFFTF


    ------------------


    import java.io.*;
    import java.util.*;

    public class E6_603
    {

    public static void main(String[] args) throws IOException,
    FileNotFoundException
    {


    String[] correctAnswer = new String[20];
    String[] studentId= new String[150];
    String[] answer= new String[20];

    int noOfStudents = 0;
    int answerNo = 0;
    int points =0;

    Scanner inFile =
    new Scanner(new FileReader("c:\\Ch9_Ex6Data.txt"));
    correctAnswer[0] = inFile.next();

    while (inFile.hasNext() && noOfStudents <150)
    {
    studentId[noOfStudents] = inFile.next();
    while (answerNo<20)
    {
    answer[answerNo]= inFile.next();
    if (answer[answerNo]==correctAnswer[answerNo])
    points = points +2;
    else
    points = points -1;

    answerNo++;
    }
    noOfStudents++;

    System.out.println("Student : " + studentId[noOfStudents] +' ' + points );

    }




    inFile.close();
    }
    }

  2. #2
    Join Date
    Apr 2006
    Posts
    2
    what's the problem???????????????????
    are u don't understand or u don't care

  3. #3
    Join Date
    Feb 2006
    Location
    Cologne - Germany
    Posts
    271
    your code looks fine, but i don't have the time to test it. can you point out what the problem with your code is particularly? do you have any errors? what's the help you want?

Similar Threads

  1. Control Arrays in VB.NET
    By Gary Nelson in forum .NET
    Replies: 277
    Last Post: 10-01-2003, 01:00 AM
  2. Microsoft's C++ bigotry
    By Phil Weber in forum .NET
    Replies: 632
    Last Post: 10-01-2003, 01:00 AM
  3. Speaking of strings...
    By Harlow in forum .NET
    Replies: 246
    Last Post: 10-26-2002, 01:30 AM
  4. Another Language
    By Steven Bell in forum .NET
    Replies: 260
    Last Post: 06-01-2001, 05:32 PM
  5. Replies: 90
    Last Post: 04-17-2001, 01:45 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center