for my menu, I have an option (case 2) in my menu to display to contents of the file ("Grades.txt"). If I enter exemplar data being:
First Name: Fred
Surname: Smith
Course: IT
Mark: 66
It saves to the file as:
Fred Smith, Computing, 66
Which is correct. However, when I choose option 2 in the menu after, to display the contents of the file, is shows as:
java.io.FileWriter@55f96302
Now I have looked around and can't find anything similar at all.
If anyone could help solve this issue, I would be grateful. Thanks
Code:
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.PrintWriter;
import java.util.Scanner;
public class ExamGrades {
    public static void main(String[] args) throws Exception {
        FileWriter grades = new FileWriter("grades.txt",true);
        BufferedWriter bw = new BufferedWriter(grades);
        PrintWriter out = new PrintWriter(bw);
        Scanner scan = new Scanner(System.in);
        int examMark =0;
        String firstName = "";
        String surName = "";
        String course = "";
        String entry = "";
        int menu =0;
        System.out.println("Welcome to the 'GradeEnter' program! ");
        System.out.println("Menu: ");
        System.out.println("1) Enter Student Grade(s)");
        System.out.println("2) View Student Grade(s)");
        System.out.println("3) Delete Grade(s)");
        System.out.println("4) Exit");
        menu = scan.nextInt();
        switch (menu) {
        case 1:
            System.out.print("Please enter student first Name: "); 
            firstName = scan.next(); 
            System.out.print("Please enter student surname: ");
            surName = scan.next();
            System.out.print("Please select student course: "); 
            course = scan.next();
            System.out.print("Please enter student mark: ");
            while (!scan.hasNextInt())
            {
                System.out.print("Please enter a valid mark: ");
                scan.next();
            }
            examMark = scan.nextInt();
            if (examMark < 40)
            {
                System.out.println("Failed");
            }
            else if (examMark >= 40 && examMark <= 49)
            {
                System.out.println("3rd");
            }
            else if (examMark >= 50 && examMark <= 59)
            {
                System.out.println("2/2");
            }
            else if (examMark >= 60 && examMark <= 69)
            {
                System.out.println("2/1");
            }
            else if (examMark >= 70 && examMark <= 100)
            {
                System.out.println("1st");
            }
            else
            {
                System.out.println("Invalid Mark");
            }
            break;
        case 2:
            System.out.println(grades); 
        case 3:
            /*          System.out.print("Please enter a the first name you want to delete: ");
            if (firstName == scan.next()) {
            grades.remove(scan.next());
            }
             */
        case 4:
            System.out.println("Thanks for using 'GradeEnter' ");
            System.exit(0);
        default:
        } 
        entry = (firstName + " " + surName + ", " + course + ", " + examMark);
        out.println(entry);
        out.close();
        scan.close();
    }
}
 
     
     
     
    