Implementing ChatGPT in Your Web Application: A Step-by-Step Tutorial
Learn how to integrate OpenAI's ChatGPT into your web application to create intelligent chatbots and enhance user interactions.
Read More →This mini project allows users to perform basic student record operations using Java OOP, collections, and file handling techniques. You’ll build a console-based application where you can add, view, search, and delete student records.
Create a class called Student to hold student data. Make it implement Serializable so it can be saved to files later.
Use an ArrayList to store Student objects dynamically.
Build a loop that shows options to the user: Add, View, Search, Delete, Exit. Use Scanner for input and switch-case to handle operations.
Ask for roll number and name, then create and add a new Student to the list.
Loop through the list and print each student's details using toString().
Ask the user for a roll number and display matching student info.
Ask for roll number and remove the student object using removeIf().
Use ObjectOutputStream and ObjectInputStream to save and load the student list to/from a file.
import java.io.*;
import java.util.*;
class Student implements Serializable {
int rollNo;
String name;
public Student(int rollNo, String name) {
this.rollNo = rollNo;
this.name = name;
}
public String toString() {
return "Roll No: " + rollNo + ", Name: " + name;
}
}
public class StudentManagementSystem {
static List students = new ArrayList<>();
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner(System.in);
while (true) {
System.out.println("1. Add\n2. View\n3. Search\n4. Delete\n5. Exit");
int choice = sc.nextInt();
switch (choice) {
case 1:
System.out.print("Enter roll no: ");
int r = sc.nextInt();
sc.nextLine();
System.out.print("Enter name: ");
String n = sc.nextLine();
students.add(new Student(r, n));
break;
case 2:
for (Student s : students)
System.out.println(s);
break;
case 3:
System.out.print("Enter roll no to search: ");
int search = sc.nextInt();
for (Student s : students)
if (s.rollNo == search)
System.out.println(s);
break;
case 4:
System.out.print("Enter roll no to delete: ");
int del = sc.nextInt();
students.removeIf(s -> s.rollNo == del);
break;
case 5:
return;
}
}
}
}
This project helps learners understand real-world applications of OOP, collections, file handling, and building command-line apps. It's a foundation for GUI-based or database-connected systems in the future.
Learn how to integrate OpenAI's ChatGPT into your web application to create intelligent chatbots and enhance user interactions.
Read More →Learn how to create web forms that are accessible to all users, including those with disabilities. This comprehensive guide covers ARIA attributes, keyboard navigation, and more.
Read More →Get the latest articles and resources delivered straight to your inbox.