Professional Documents
Culture Documents
Finalvanshviraj Removed
Finalvanshviraj Removed
Finalvanshviraj Removed
2. Student Class:
The Studentclass represents individual students in the system.
It has attributes such as name and rollNumber .
The class includes a constructor to initialize a Studentobject with
a name and roll number, as well as getter methods to retrieve
these attributes.
3. Methods in AttendanceSystem:
addStudent(): Prompts the user to input the name and roll
number of a student, creates a Student object, and adds it to the
array of students.
4. Array of Students:
The program maintains an array studentsto store instances of
the Student class.
The size of the array is set to accommodate a maximum of 60
students (private static Student[] students =
new Student[60]).
The variable studentCountkeeps track of the number of
students currently stored in the array.
5. Input Validation:
The program validates user input to ensure correctness. For
example, it checks if the entered roll number is valid or if the
student to be removed exists in the system.
6. User Interface:
The user interface is text-based, displaying options and prompts to
the user via the console.
Users interact with the program by entering choices and providing
input when prompted.
Overall, this program provides a simple yet effective way to manage student
attendance data through basic CRUD (Create, Read, Update, Delete) operations.
import java.util.Scanner;
maximum of 60 students
int choice;
do {
System.out.println("4. Exit");
choice = scanner.nextInt();
switch (choice) {
case 1:
addStudent();
break;
case 2:
removeStudent();
break;
case 3:
viewStudents();
break;
case 4:
break;
default:
System.out.println("Invalid Choice!");
scanner.close();
studentCount++;
if (index != -1) {
studentCount--;
} else {
if (studentCount == 0) {
} else {
System.out.println("\nStudent List:");
if (students[i].getRollNumber() == rollNumber) {
return i;
return -1;
}
class Student {
this.name = name;
this.rollNumber = rollNumber;
return name;
return rollNumber;
}
Output :-
Add Student: Allows users to input the name and roll number of a student and
adds them to the system.
View Students: Displays the list of students currently present in the system, showing their
names and roll numbers.
Remove Student: Enables users to remove a student from the system by entering the roll
number of the student they wish to remove.
Conclusion: