Hi All,
Thanks to everyone who helped work out my probs last semester. Ended up with a B in Computer Science class. Even though I thought I was going to fail. Anyway, New semester another new problem. I have done the assignment and keep running it. I keep getting an error I'm not understanding. We're using JCreator slow, but its ok. Any suggestions or help, always GREATLY Appreciated.
/**
*
* This class reads in exam scores from a text file, averages them, and writes the resulting average to a new text file.
*/
import java.util.Scanner;
import java.io.*;
public class ScoreAverager
{
//default constructor
public ScoreAverager()
{
}
//method to read the file, average the grades, and print the new file
//an IO exception is thrown if the file can't be read or a new file cannot be written to
public void gradeAvg() throws IOException
{
Scanner input = new Scanner(System.in);
double sum = 0;
int count = 0;
double classAverage = 0;
String currentClass = null;
File inFile = new File("C:\\My Documents\\examscores.txt");
PrintWriter output = new PrintWriter(new File("C:\\Documents and Settings\\nwindAverages.txt"));
try
{
input = new Scanner(inFile);
while(input.hasNext())
{
currentClass = input.next();
int var1 = input.nextInt();
while(var1 != -9999)
{
sum += var1;
count++;
var1 = input.nextInt();
}
classAverage = sum/count;
System.out.println(currentClass);
System.out.println(classAverage);
output.println("Class : " + currentClass);
output.println("Class Average: " + classAverage);
output.println();
}
}
catch (IOException e)
{
System.out.println(e);
System.exit(0);
}
finally
{
output.close();
// input.close();
}
}
}
ERROR:
java.lang.NoSuchMethodError: main
Exception in thread "main"
Process completed.