Day 4: Java Console Based Student Grade Manager

AyushAyush
3 min read

What I Built Today

Today, I built a console-based Student Grade using Java. This project uses an ArrayList, Hash Map and txt file to track grades. Users can perform the following operations:

  • Add a student.

  • Add subjects & marks for the respective student.

  • Show student details.

  • Save to and load from a .txt file.

What I Struggled With

  1. Java I/O: I am still not really comfortable working with I/O. I can work just fine with Character Stream Classes like BufferedReader & BufferedWriter, though. I plan on working with Byte Stream classes next.

  2. Git & GitHub: Much much better than yesterday, but I still struggle with Commit Messages & GitHub commands. On a brighter note though, I have somewhat developed a system for When & How to commit though.

  3. Starting from Scratch: I don’t think the current me can come up with classes, methods etc to work on a project from scratch. I won’t ask for boiler plates from GPT.

How I Challenged Myself

  1. Using Official Documentation as a Resource: Again, I referred to the official Oracle Java Documentation. It was not as bad as it before.

  2. Keeping a To Do: I have started to keep a note of things I have to research about after each project and tweaks, checkpoints for the project.

The Final Output

  1. Project Structure

     student-grade-manager/
      ┣ src/
      ┃ ┣ Student.java
      ┃ ┣ GradeManager.java
      ┃ ┗ StudentApp.java
      ┣ data/
      ┃ ┗ students.txt
      ┗ README.md
    
  2. Key Code Snippets

     public void saveToFile(String filePath) {
             try (BufferedWriter writer = new BufferedWriter(new FileWriter(filePath))) {
                 for (Student student : studentList) {
                     writer.write(student.getRollNo() + "," + student.getName());
                     writer.newLine();
                 }
                 System.out.println(studentList.size() + " records saved.");
             } catch (IOException e) {
                 e.printStackTrace();
             }
         }
    
     public void loadFromFile(String filename) {
             try (BufferedReader reader = new BufferedReader(new FileReader(filename))) {
                 String line;
                 while ((line = reader.readLine()) != null) {
                     String[] parts = line.split(",");
                     int rollNo = Integer.parseInt(parts[0]);
                     String name = parts[1];
                     studentList.add(new Student(name, rollNo));
                 }
                 System.out.println("Student Record Imported Successfully!");
             } catch (IOException e) {
                 e.printStackTrace();
             }
         }
    

What's Next

  1. Personal Reference & Resource Sheet: I plan on becoming a Backend Engineer. So I will start working on having a reference sheet for all sort of things. For instance:

    1. Dev Ops Sheet: For Dev Ops Articles & Resources Link. Like this Git Commit Convention or this excellent article on Git from The Odin Project.

    2. Core Java Notes: Following the 80 20 Rule, keep the most important topics with parts you struggle with.

  2. Fundamentals: I will have a fixed time and reference point to revisit the Fundamentals and again create my reference sheet from scratch.

  3. 80/20: Since my goal is to become a Backend Engineer, I will start focusing heavily on the backend concepts and start tailoring my projects to that.

0
Subscribe to my newsletter

Read articles from Ayush directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Ayush
Ayush