This is my part of my code. Basically I am trying to store the values from double Avg and char gradeLetter in the arrays doubleAVG and charGRADE. What im getting so far is that on the first loop, lets say Avg = 2 then that will be a stored in the file, but if there is a second loop and the value of Avg changes to 3 then 3 will be saved in the file twice. It deletes 2 and saves the number 3 twice. How can i fix that? I want the first loop to store the first value of Avg that can be 2 and then on the second loop to store the new value of Avg that could be 3 but without overwriting the 2. IGNORE THE COMMENTS.
try {
FileWriter fw = new FileWriter(fileN);
for (int count = 0; count < students; count++) {
doubleAVG = new double[students];
charGRADE = new char[students];
doubleAVG[count] = Avg;
charGRADE[count] = gradeLetter;
fw.write("This is the grade of: " + FirstName + " " + LastName
+ " ");
fw.write(String.valueOf(doubleAVG[count]) + " ");
fw.write(charGRADE[count]);
}
fw.close();
} catch (Exception e) {
System.out.println(e);
}
IGNORE THE COMMENTS.: Please, don't write in upper case. And why don't you remove these useless comments to make a more readable code?