Module 10

Module 10: Java in Practice – Mini Projects and Next Steps

Module 10: Java in Practice – Mini Projects and Next Steps

10.1 Introduction

In this final module, we consolidate what we’ve learned in the previous modules by building practical mini projects. This helps solidify your understanding and prepares you for real-world Java development.

10.2 Mini Project 1: Student Management System

Build a simple console-based program to manage student records using classes, objects, arrays, and file handling.

import java.io.*;
import java.util.*;

class Student {
    String name;
    int age;
    String id;

    Student(String id, String name, int age) {
        this.id = id;
        this.name = name;
        this.age = age;
    }

    public String toString() {
        return id + " | " + name + " | " + age;
    }
}

public class StudentManagement {
    static ArrayList<Student> students = new ArrayList<>();

    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        while(true) {
            System.out.println("1. Add Student\n2. Display Students\n3. Exit");
            String choice = reader.readLine();
            if(choice.equals("1")) {
                System.out.print("ID: "); String id = reader.readLine();
                System.out.print("Name: "); String name = reader.readLine();
                System.out.print("Age: "); int age = Integer.parseInt(reader.readLine());
                students.add(new Student(id, name, age));
            } else if(choice.equals("2")) {
                for(Student s : students) System.out.println(s);
            } else break;
        }
    }
}

10.3 Mini Project 2: Bank Account Simulator

Simulate a bank account with deposit, withdraw, and balance check functionalities using classes, encapsulation, and exception handling.

class BankAccount {
    private double balance;

    BankAccount(double initialBalance) {
        this.balance = initialBalance;
    }

    public void deposit(double amount) {
        balance += amount;
    }

    public void withdraw(double amount) throws Exception {
        if(amount > balance) throw new Exception("Insufficient funds");
        balance -= amount;
    }

    public double getBalance() {
        return balance;
    }
}

public class BankSimulator {
    public static void main(String[] args) {
        BankAccount account = new BankAccount(1000);
        try {
            account.deposit(500);
            account.withdraw(200);
            account.withdraw(2000); // Will throw exception
        } catch(Exception e) {
            System.out.println("Error: " + e.getMessage());
        }
        System.out.println("Balance: $" + account.getBalance());
    }
}

10.4 Mini Project 3: Todo List Application

Implement a console-based Todo list application with the following features: add tasks, remove tasks, view all tasks, and save/load tasks to/from a file.

import java.io.*;
import java.util.*;

public class TodoApp {
    static ArrayList<String> tasks = new ArrayList<>();

    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        loadTasks();
        while(true) {
            System.out.println("1. Add Task\n2. View Tasks\n3. Remove Task\n4. Exit");
            String choice = reader.readLine();
            if(choice.equals("1")) {
                System.out.print("Task: "); String task = reader.readLine();
                tasks.add(task);
            } else if(choice.equals("2")) {
                for(int i=0; i<tasks.size(); i++) System.out.println((i+1) + ". " + tasks.get(i));
            } else if(choice.equals("3")) {
                System.out.print("Task number to remove: "); int index = Integer.parseInt(reader.readLine());
                if(index > 0 && index <= tasks.size()) tasks.remove(index-1);
            } else break;
        }
        saveTasks();
    }

    static void loadTasks() {
        try {
            File file = new File("tasks.txt");
            if(file.exists()) {
                BufferedReader br = new BufferedReader(new FileReader(file));
                String line;
                while((line = br.readLine()) != null) tasks.add(line);
                br.close();
            }
        } catch(IOException e) { e.printStackTrace(); }
    }

    static void saveTasks() {
        try {
            BufferedWriter bw = new BufferedWriter(new FileWriter("tasks.txt"));
            for(String t : tasks) bw.write(t + "\n");
            bw.close();
        } catch(IOException e) { e.printStackTrace(); }
    }
}

10.5 Next Steps for Java Learning

  • Learn Java Collections Framework for advanced data structures.
  • Explore Java Generics for type-safe reusable code.
  • Understand multithreading and concurrency for building performant applications.
  • Get familiar with Java GUI frameworks (Swing, JavaFX) or web development using Spring Boot.
  • Work on more real-world projects: inventory system, chat app, banking system, or file parser tools.

10.6 Summary

  • Module 10 reinforces Java knowledge through mini projects.
  • Practical coding solidifies understanding of OOP, file handling, exceptions, and streams.
  • Next steps involve exploring advanced Java concepts and building full-fledged applications.

🧠 Practice Exercises

  • Create a mini Library Management System with book borrowing/returning functionalities.
  • Build a contact manager application with file persistence and search functionality.
  • Extend the Bank Account simulator to handle multiple accounts and transactions.
  • Implement a basic console-based quiz application storing questions and scores in files.

End of Module 10 — Java in Practice

Latest Notes

View Archive [ -> ]