-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAttendance-Management-System.cpp
More file actions
152 lines (150 loc) · 3.6 KB
/
Attendance-Management-System.cpp
File metadata and controls
152 lines (150 loc) · 3.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
int max_students = 100; // structure defination
struct Student
{
string name;
int roll_no;
char grade;
int attendence;
};
int main()
{
Student students[max_students];
int studentcount = 0;
int choice;
LOOP:
cout << "-------Welcome to Attendence Management System-------" << endl;
cout << "--------------Are you Admin or Student---------------" << endl;
cout << "1. Admin View" << endl;
cout << "2. Student View" << endl;
cout << "Enter your choice: ";
cin >> choice;
switch (choice)
{
case 1:
do
{
cout << "-------Admin View-------" << endl;
cout << "1. Add Student" << endl;
cout << "2. Mark Attendance" << endl;
cout << "3. Display Attendance" << endl;
cout << "4. Go back to admin or student selection section" << endl;
cout << "5. Exit" << endl;
cout << "Enter your choice: ";
cin >> choice;
switch (choice)
{
case 1:
if (studentcount < max_students)
{
cout << "Enter student name: ";
cin >> students[studentcount].name;
cout << "Enter roll no: ";
cin >> students[studentcount].roll_no;
cout << "Enter grade: ";
cin >> students[studentcount].grade;
studentcount++;
cout << "Student Added Successfully" << endl;
}
else
{
cout << "Maximun number of students added" << endl;
}
break;
case 2:
if (studentcount == 0)
{
cout << "No student to mark Attendence. First add students" << endl;
}
else
{
int rollnumber;
cout << "Enter roll no: ";
cin >> rollnumber;
int foundIndex = -1;
for (int i = 0; i < studentcount; i++)
{
if (students[i].roll_no == rollnumber)
{
students[i].attendence = 1;
cout << "Attendence Marked successfully" << endl;
foundIndex = i;
break;
}
}
if (foundIndex == -1)
{
cout << "Student not found." << endl;
}
}
break;
case 3:
if (studentcount == 0)
{
cout << "No student to mark Attendence. First add students" << endl;
}
else
{
cout << "-----Attendence Record---" << endl;
cout << setw(20) << "Name" << setw(20) << "Roll_no" << setw(20) << "Grade" << setw(20) << "Attendence" << endl;
for (int i = 0; i < studentcount; i++)
{
cout << setw(20) << students[i].name << setw(20) << students[i].roll_no << setw(20) << students[i].grade << setw(20);
if (students[i].attendence == 1)
cout << "Present" << endl;
else
cout << "Absent" << endl;
}
}
break;
case 4:
goto LOOP;
case 5:
cout << "Exiting..." << endl;
break;
default:
cout << "Invalid choice!" << endl;
}
} while (choice != 5);
break;
case 2:
do
{
cout << "-------Student View-------" << endl;
cout << "1. View Attendance\n";
cout << "2. Exit\n";
cout << "Enter your choice: ";
cin >> choice;
switch (choice)
{
case 1:
if (studentcount == 0)
{
cout << "No student to mark Attendence. First add students" << endl;
}
else
{
cout << setw(20) << "Name" << setw(20) << "Roll_no" << setw(20) << "Grade" << setw(20) << "Attendence" << endl;
for (int i = 0; i < studentcount; i++)
{
cout << setw(20) << students[i].name << setw(20) << students[i].roll_no << setw(20) << students[i].grade << setw(20);
if (students[i].attendence == 1)
cout << "Present" << endl;
else
cout << "Absent" << endl;
}
}
break;
case 2:
cout << "Exiting...";
break;
default:
cout << "Invalid choice!";
}
} while (choice != 2);
break;
}
}