-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstudent_mng.java
More file actions
282 lines (265 loc) · 9.74 KB
/
student_mng.java
File metadata and controls
282 lines (265 loc) · 9.74 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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
import java.util.*;
class Student {
int roll, s_mark1, s_mark2, s_mark3;
String name, sub1, sub2, sub3;
int avg, total;
void setName() {
Scanner sc = new Scanner(System.in);
System.out.print("Enter Student Name: ");
name = sc.nextLine();
}
String getName() {
return name;
}
void showName() {
System.out.println("Student Name: " + name);
}
void setRoll() {
Scanner sc = new Scanner(System.in);
System.out.print("Enter Roll No: ");
roll = sc.nextInt();
}
int getRoll() {
return roll;
}
void showRoll() {
System.out.println("Roll no: " + roll);
}
void setSub() {
if (!(sub1 == null)) {
System.out.println("Subject already Entered");
return;
}
Scanner sc = new Scanner(System.in);
System.out.print("Enter Subject 1 Name: ");
sub1 = sc.nextLine();
System.out.print("Enter Subject 2 Name: ");
sub2 = sc.nextLine();
System.out.print("Enter Subject 3 Name: ");
sub3 = sc.nextLine();
}
void getSub() {
if (sub1 == null) {
System.out.println("Please enter Subject Name");
return;
}
System.out.println("Subject 1 Name: " + sub1);
System.out.println("Subject 2 Name: " + sub2);
System.out.println("Subject 3 Name: " + sub3);
}
void setMark() {
if (!(s_mark1 == 0)) {
System.out.println("Marks already Entered");
return;
}
Scanner sc = new Scanner(System.in);
System.out.print("Enter Subject 1 Marks: ");
s_mark1 = sc.nextInt();
System.out.print("Enter Subject 2 Marks: ");
s_mark2 = sc.nextInt();
System.out.print("Enter Subject 3 Marks: ");
s_mark3 = sc.nextInt();
}
void getMark() {
if (s_mark1 == 0) {
System.out.println("Please enter Marks");
return;
}
System.out.println("Subject 1 Marks" + s_mark1);
System.out.println("Subject 2 Marks" + s_mark2);
System.out.println("Subject 3 Marks" + s_mark3);
}
void getTotal() {
total = s_mark1 + s_mark2 + s_mark3;
System.out.println("Total Marks: " + total);
}
void getAvg() {
avg = (s_mark1 + s_mark2 + s_mark3) / 3;
System.out.println("Average: " + avg);
}
void getGrade(){
int mark=(s_mark1 + s_mark2 + s_mark3) / 3;
if(mark>90){
System.out.println("Grade: A+");
}else if(mark>80){
System.out.println("Grade: A");
}else if(mark>70){
System.out.println("Grade: B");
}else if(mark>60){
System.out.println("Grade: C");
}else if(mark>50){
System.out.println("Grade: D");
}else{
System.out.println("Grade: F");
}
}
void show() {
if (getStatus() == 0) {
System.out.println("No data Found");
return;
}
showRoll();
showName();
System.out.println(sub1 + ": " + s_mark1);
System.out.println(sub2 + ": " + s_mark2);
System.out.println(sub3 + ": " + s_mark3);
getTotal();
getAvg();
getGrade();
}
int getStatus() {
if (sub1 == null || s_mark1 == 0) {
return 0;
} else {
return 1;
}
}
}
class student_mng {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
Student arr[];
int st, ch;
System.out.print("Enter number of Students: ");
st = sc.nextInt();
arr = new Student[st];
for (int i = 0; i < st; i++) {
arr[i] = new Student();
arr[i].setRoll();
arr[i].setName();
}
do {
System.out.println("===----------------Student Management---------------===");
System.out.println("1.Show Individual Student");
System.out.println("2.Enter Subject Name");
System.out.println("3.Enter Subject Marks");
System.out.println("4.Student Report");
System.out.println("5.Update Student Details");
System.out.println("6.Exit");
System.out.print("Enter Your Choice: ");
ch = sc.nextInt();
int ck, temp = 0;
switch (ch) {
case 1:
temp = 0;
for (int i = 0; i < st; i++) {
System.out.println(arr[i].getRoll() + ". " + arr[i].getName());
}
System.out.print("Enter Roll no: ");
ck = sc.nextInt();
for (int i = 0; i < st; i++) {
if (arr[i].getRoll() == ck) {
arr[i].show();
temp = 1;
break;
}
}
if (temp == 0) {
System.out.println("Invalid Roll no!!");
}
break;
case 2:
temp = 0;
for (int i = 0; i < st; i++) {
System.out.println(arr[i].getRoll() + ". " + arr[i].getName());
}
System.out.print("Enter Roll no: ");
ck = sc.nextInt();
for (int i = 0; i < st; i++) {
if (arr[i].getRoll() == ck) {
temp = 1;
arr[i].setSub();
break;
}
}
if (temp == 0) {
System.out.println("Invalid Roll no!!");
}
break;
case 3:
temp = 0;
for (int i = 0; i < st; i++) {
System.out.println(arr[i].getRoll() + ". " + arr[i].getName());
}
System.out.print("Enter Roll no: ");
ck = sc.nextInt();
for (int i = 0; i < st; i++) {
if (arr[i].getRoll() == ck) {
temp = 1;
arr[i].setMark();
break;
}
}
if (temp == 0) {
System.out.println("Invalid Roll no!!");
}
break;
case 4:
temp = 0;
for (int i = 0; i < st; i++) {
if (arr[i].getStatus() == 0) {
temp = 1;
System.out.println("Please Fill " + arr[i].getName() + "'s Data..");
break;
}
}
if (temp == 0) {
System.out.println("-------Student Report-------");
for (Student s : arr) {
s.show();
System.out.println(' ');
}
}
break;
case 5:
temp = 0;
for (int i = 0; i < st; i++) {
System.out.println(arr[i].getRoll() + ". " + arr[i].getName());
}
System.out.print("Enter Roll no: ");
ck = sc.nextInt();
for (int i = 0; i < st; i++) {
if (arr[i].getRoll() == ck) {
temp=1;
int ich;
do {
System.out.println("1. Update Name");
System.out.println("2. Update Subject Names");
System.out.println("3. Update Subject Marks");
System.out.println("4. Back");
System.out.print("Enter Your Choice: ");
ich = sc.nextInt();
switch (ich) {
case 1:
arr[i].setName();
break;
case 2:
arr[i].setSub();
break;
case 3:
arr[i].setMark();
break;
case 4:
break;
default:
System.out.println("Invalid Input");
break;
}
} while (ich != 4);
break;
}
}
if (temp == 0) {
System.out.println("Invalid Roll no!!");
}
break;
case 6:
System.out.println("Thank you for using RDS code, Have a Great Day");
break;
default:
System.out.println("Invalid Choice, Try again..");
break;
}
} while (ch != 6);
}
}