-
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();
}
}
-
what's the problem???????????????????
are u don't understand or u don't care
-
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
-
By Gary Nelson in forum .NET
Replies: 277
Last Post: 10-01-2003, 12:00 AM
-
By Phil Weber in forum .NET
Replies: 632
Last Post: 10-01-2003, 12:00 AM
-
Replies: 246
Last Post: 10-26-2002, 12:30 AM
-
By Steven Bell in forum .NET
Replies: 260
Last Post: 06-01-2001, 04:32 PM
-
Replies: 90
Last Post: 04-17-2001, 12: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
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks