I wrote this program, however I can't seem to get it to read a string of numbers. Right now it inputs the numbers as single digits and also counts the white spaces. I thought that StringTokenizer would work, but I can't get it to. It compiles, but then errors out. Can someone Please help me out here.
import java.text.*;
import java.io.*;
import java.util.*;
public class GradeCount
{
/**
* The main program for the GradeSum class
*
* @param args -- not used
*/
public static void main(String[] args) throws FileNotFoundException, IOException
{
int count; // total number of enteries
int sum; // overall total of all entries
int lowvalue, highvalue; // range variables
int Acount, Bcount, Ccount, Dcount, Fcount; // grade variables
int next;
int score;
BufferedReader inFile = new
BufferedReader(new FileReader("a:\\test.txt"));
PrintWriter outFile = new
PrintWriter(new FileWriter("a:\\output.txt"));
{
System.out.println();
System.out.println("~Grade Summarizer~");
System.out.println(
"Please enter the grades to be summarized,"
+ " one grade per line.");
System.out.println(
"When finished, enter a '-1' to signal the"
+ " end of the grades.");
System.out.println();
// initialise instance variables
count = 0;
Acount = 0;
Bcount = 0;
Ccount = 0;
Dcount = 0;
Fcount = 0;
score = inFile.read();
while (score >= 0) // properties for calculations
{
// range properties
// grade variables
if (score >= 90)
Acount++;
else if (score >= 80)
Bcount++;
else if (score >= 70)
Ccount++;
else if (score >= 60)
Dcount++;
else
Fcount++;
score = inFile.read();
}
{
/**
* Gets users input and checks to see if positive; program
* will not allow negative inputed values.
*/
// outputs amount of each value
System.out.println("Number of A's: " + Acount);
System.out.println("Number of B's: " + Bcount);
System.out.println("Number of C's: " + Ccount);
System.out.println("Number of D's: " + Dcount);
System.out.println("Number of F's: " + Fcount);
}
}
}}
Thanks,
Jenie