Thank you for all of your help. I put all of that stuff in, but now my problem is that I am only outputting the even number of names. I have 10 input names and the output file is only containing names 2,4,6,8, and 10??? Any thoughts??? Thanks again for the help!!!
HERE IS THE CODE
import java.util.*;
import java.io.*;
import java.text.DecimalFormat;
public class Grade7
{
static BufferedReader keyboard =
new BufferedReader(new InputStreamReader(System.in));
public static void main (String[] args) throws IOException, FileNotFoundException, NoSuchElementException
{
double test1, test2, test3, test4, test5;
double average;
String firstName;
String grade;
StringTokenizer st;
BufferedReader inFile = new
BufferedReader(new FileReader("C:\\test1.txt"));
PrintWriter outFile = new
PrintWriter(new FileWriter("C:\\testavg.out"));
DecimalFormat twoDecimal =
new DecimalFormat("0.00");
outFile.println("Name" + "\t\t" + "Test1" + "\t" + "Test2" + "\t" + "Test3" + "\t" + "Test4" + "\t" + "Test5" + "\t" + "Average" + "\t" + " " + "Grade");
String myLine = inFile.readLine();
while ( myLine != null )
{
st = new StringTokenizer( myLine );
st = new StringTokenizer (inFile.readLine());
firstName = st.nextToken();
test1 = Double.parseDouble(st.nextToken());
test2 = Double.parseDouble(st.nextToken());
test3 = Double.parseDouble(st.nextToken());
test4 = Double.parseDouble(st.nextToken());
test5 = Double.parseDouble(st.nextToken());
average = (test1 + test2 + test3 + test4 + test5) /5.0;
if(average >= 90.0)
grade = "A";
else if(average >= 80.0)
grade = "B";
else if(average >= 70.0)
grade = "C";
else if(average >= 60.0)
grade = "D";
else
grade = "F";
outFile.println(firstName + " \t\t" + test1 + "\t" + test2 + "\t" + test3 + "\t" + test4 + "\t" + test5 + "\t" + twoDecimal.format(average) + "\t" + " " + grade);
myLine = inFile.readLine();
}
outFile.close();
}
}
HERE IS THE INPUT FILE:
Balto85 83 77 91 76
Mickey80 90 95 93 48
Minnie78 81 11 90 73
Doc92 83 30 69 87
Goofy23 45 96 38 59
Duckey60 85 45 39 67
Grumpy27 31 52 74 83
Sunny93 94 89 77 97
Piggy79 85 2893 82
Pluto85 72 49 75 63
HERE IS MY OUTPUT FILE:
NameTest1Test2Test3Test4Test5Average Grade
Mickey 80.090.095.093.048.081.20 B
Doc 92.083.030.069.087.072.20 C
Duckey 60.085.045.039.067.059.20 F
Sunny 93.094.089.077.097.090.00 A
Pluto 85.072.049.075.063.068.80 D