Error problem
My problem is as follows. My program reads a file of a list of student and their grades and prints out their score and and grade and then gives a total of the number of letter grades. My problem is that my toString method is returning a hexidecimal form of the String. Any suggestions would be helpful. Here is the code.
import java.io.*;
import java.util.ArrayList;
import java.util.StringTokenizer;
public class StudentClient
{
// StringTokenizer variables
private static FileInputStream inFile;
private static InputStreamReader inReader;
private static BufferedReader reader;
private static StringTokenizer token;
// Input string declaration
private static String inputLine;
// Necessary computation and presentation variables
private static int count = 0; // Counts the number of students
private static String output,temp,temp2,temp3;
private static char compare;
private static int asum, bsum, csum, dsum, fsum;
private static double average, percenta, percentb, percentc, percentd, percentf;
private static double avsum;
public static void main (String [] args) throws IOException
{initFile();
inputAnalyze();
inFile.close();
}
// Prepare file for input
public static void initFile() throws IOException
{
inFile = new FileInputStream ("C:\\Documents and Settings\\Bill\\Desktop\\QuizTF.txt"); // Insert correct file location
inReader = new InputStreamReader(inFile);
reader = new BufferedReader(inReader);
}
// Take data from file, analyze word and suffix structures, and compile plurals and suffix additions
public static void inputAnalyze() throws IOException
{
// Start first constructor and instantiate student object
Student key = new Student();
// Setup ArrayList
ArrayList students = new ArrayList();
// Read data line and pass it into created student
inputLine = reader.readLine();
key.setCorrectAns(inputLine);
// Read student scores data lines
inputLine = reader.readLine();
while (inputLine != null){
count++;
// Place string in an ArrayList
students.add(new Student(inputLine));
// Read next line for while loop
inputLine = reader.readLine();
}
// Calculate average and percentages
for (int i=0;i<count;i++){
Object Test = students.get(i);
output = ((Student)Test).toString();
// Testing only
System.out.println(output);
token = new StringTokenizer(temp);
temp2 = token.nextToken();
avsum += Double.parseDouble(token.nextToken());
temp3 = token.nextToken();
compare = temp3.charAt(0);
if (compare == 'A')
asum++;
if (compare == 'B')
bsum++;
if (compare == 'C')
csum++;
if (compare == 'D')
dsum++;
if (compare == 'F')
fsum++;
average = avsum/count;
percenta = asum/count;
percentb = bsum/count;
percentc = csum/count;
percentd = dsum/count;
percentf = fsum/count;
}
// Output results
System.out.println("The student results are as follows: " + '\n');
for(int i=0; i><count; i++){
System.out.println(students.get(i));
}
System.out.println('\n' + count + " students took the test.");
System.out.println("The class average is: " + average + "%");
System.out.println(percenta + "% of students received an A");
System.out.println(percentb + "% of students received a B");
System.out.println(percentc + "% of students received a C");
System.out.println(percentd + "% of students received a D");
System.out.println(percentf + "% of students received an F");
}
}>

