Java Help
Posted: December 22nd, 2006, 18:12
Any java boffins about that can check this for me. It keeps returning Grade as a null instead of the Character its ment to be set at. I need a fresh pair of eyes as I must be looking to hard at it now. Any help would be much appreciated.
Code: Select all
/****************************************************************************
* Program Name : Student Grant *
* Author : David Gillespie *
* Date : 18/12/06 *
* The program will read in 10 student names and marks from a text document*
* The system will ask the user to set grades (i.e A > 80) the program will*
* convert the marks into the grades specified by the user and Save it in *
* a .txt file. *
****************************************************************************/
//Calling function for the program to use to keep size down
import java.io.*;
import java.util.*;
public class studentGrant
{//Start of class Student Grant
//set Constant for number of students
final static int No_of_Students = 10;
//allow input from keyboard
static BufferedReader keyboard = new BufferedReader(new InputStreamReader(System.in));
//********************Create Records*************************************
static class Student_Grades{
String Name;
int Mark;
Character Grade;
}//End of record Declaration
//******************** Read Marks File *********************************
static boolean readMarksFile (Student_Grades[] Grades)
{//read the information from file. If no file exists then trap it in an error
//variable declaration section
boolean FileFound = false;
try
{//Specify and access chosen file
//variable declaration section
StringTokenizer Tokenizer;
String Dir_Name ="C:\\Java\\text\\";
String File_Name="Marks.txt";
File Input = new File(Dir_Name, File_Name);
String LineInFile, Firstname, Surname;
BufferedReader tempFile = new BufferedReader(new FileReader(Input));
for(int loop = 0; loop < No_of_Students; loop++)
{//Sets Values from Marks Files
LineInFile = tempFile.readLine();
Tokenizer = new StringTokenizer(LineInFile);
Firstname = Tokenizer.nextToken();
Surname =Tokenizer.nextToken();
Grades[loop].Name = (Firstname+" "+Surname);
Grades[loop].Mark = Integer.parseInt(Tokenizer.nextToken());
}//end for
//Tells the calling function the file was found
FileFound = true;
//Closes the Marks file after use
tempFile.close();
}//end try
catch(FileNotFoundException error)
{//Insert Comment Here
System.err.println(error);
}//end no file catch
catch(IOException error)
{//Insert Comment Here
System.err.println(error);
}//end ioexception catch
finally
{//Insert Comment Here
return (FileFound);
}//end finally
}