Welcome to Egypt Forums Mark forums read | Egypt Main Page
Egypt Forums
Arabic Movies



Programming Languages A Place for windows applications programs and programmers .

Programming Languages Thread, Java programming problem in Programming , WebDesign & Development; I'm having a problem with a Java assignment. We are using arrays to store test grades and compare them to ...

Short Link: http://forum.egypt.com/enforum/showthread.php?t=26563


Reply
LinkBack Thread Tools Display Modes
Java programming problem
 
 
Senior Member

Reply With Quote
 
Join Date: Dec 2008
Posts: 18,122
08-02-2009, 02:21 AM
 
I'm having a problem with a Java assignment. We are using arrays to store test grades and compare them to an answer key, also stored in an array. The input file is organized so that the first line contains the the correct answers. Each following...

<div>I'm having a problem with a Java assignment. We are using arrays to store test grades and compare them to an answer key, also stored in an array. The input file is organized so that the first line contains the the correct answers. Each following line contains the students ID a white space, then their test answers. If the question was not answered, a whitespace apears in place of T or F.

I am able to read the first line of the input file and fill the answerKey array, but when I try to start pulling in the ID's and Responces, I get a <font size="2"><font color="#000080">
java.util.NoSuchElementException. The following code is what I have so far and includes a loop for testing.<font color="#000080">

package chapter9;
import java.util.*;
import java.io.*;
public class RunApp9 {

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

{

Scanner inFile =
new Scanner(new FileReader ("h:\\Game Developement 1\\workspace\\GameDesign1\\src\\chapter9\\Ch9_Ex6D ata.txt"));
PrintWriter outFile =
new PrintWriter("h:\\Game Developement 1\\workspace\\GameDesign1\\src\\chapter9\\test2.tx t");

String key = inFile.next();
int testLength = key.length();
char[] answerKey = new char[testLength];


for (int i = 0; i < testLength; i++)
{
answerKey[i] = key.charAt(i);
}

String[][] responces = new String[4][2];

for (int i = 0; i < responces.length;i++)
{
for (int j = 0;j < responces[i].length;j++)
{
responces[i][j] = "";
}
}


while(inFile.hasNext())
{

for (int i = 0; i < responces.length;i++)
{
for (int j = 0;j < responces[i].length;j++)
{
<font size="2">responces[0][i]= inFile.next(); //<b><font color="red">
 
 
 
Reply

Programming Languages Thread, Java programming problem in Programming , WebDesign & Development; I'm having a problem with a Java assignment. We are using arrays to store test grades and compare them to ...

Short Link: http://forum.egypt.com/enforum/showthread.php?t=26563


Bookmarks

Tags
java, problem, programming


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump