-
Notifications
You must be signed in to change notification settings - Fork 0
/
oops
195 lines (172 loc) · 7.98 KB
/
oops
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
import java.util.*;
class Details{
int rollnumber, fee, yearOfStudy;
long aadharnumber;
String name, DOB, gender, address;
public Details(int id, String name, String gender, Long aadharnumber, String DOB, int fee, int yearOfStudy, String address){
this.rollnumber = rollnumber;
this.name = name;
this.gender = gender;
this.aadharnumber = aadharnumber;
this.DOB = DOB;
this.fee = fee;
this.yearOfStudy = yearOfStudy;
this.address = address;
}
}
class Sdnt{
public static void main(String[] args) {
Scanner sc = new Scanner (System.in);
ArrayList <Details> sdnt = new ArrayList<Details>();
int rollnumber, fee, yearOfStudy,s_rn,count = 0,co;
long aadharnumber;
String name, DOB, gender, address;
boolean f = true;
System.out.println("Menu");
System.out.println("1. Add Student Details\n2. View Single Student Details\n3. View All Student Details\n4. Update Student Details\n5. Delete Student Details\n6. exit");
while(f){
System.out.print("Enter your choice : ");
int n = sc.nextInt();
boolean flag = false;
switch(n){
case 1 :
System.out.println("Enter the details\n");
System.out.print("Enter Rollnumber : ");
rollnumber = sc.nextInt();
System.out.print("Enter Name : ");
name = sc.next();
System.out.print("Enter Gender (M/F/O) : ");
gender = sc.next();
System.out.print("Enter Aadhar number : ");
aadharnumber = sc.nextLong();
System.out.print("Enter DOB(DD/MM/YYYY) : ");
DOB = sc.next();
System.out.print("Enter Fees : ");
fee = sc.nextInt();
System.out.print("Enter the Year Of Study : ");
yearOfStudy = sc.nextInt();
System.out.print("Enter the address : ");
address = sc.next();
sdnt.add(new Details(rollnumber, name, gender, aadharnumber, DOB, fee, yearOfStudy, address));
count++;
System.out.println("Student Details added sucessfully !");
break;
case 2 :
System.out.print("Enter the Roll number : ");
s_rn = sc.nextInt();
System.out.println("____________");
System.out.println("|ROLLNUMBER\t|NAME\t|GENDER\t|AADHAR NUMBER\t|DOB\t\t|FEE\t|STUDY\t|ADDRESS\t|");
System.out.println("____________");
for(Details d : sdnt){
if(s_rn == d.rollnumber){
System.out.println("|"+d.rollnumber+"\t|"+d.name+"\t|"+d.gender+"\t|"+d.aadharnumber+"\t|"+d.DOB+"\t|"+d.fee+"\t|"+d.yearOfStudy+"\t\t|"+d.address+"\t\t|");
System.out.println("____________");
flag = true;
break;
}
}
if(!flag){
System.out.println("Incorrect ROLL NUMBER, PLEASE ENTER CORRECT ROLL NUMBER ");
}
break;
case 3 :
System.out.println("The List of the students are : ");
System.out.println("____________");
System.out.println("|ROLLNUMBER\t|NAME\t|GENDER\t|AADHAR NUMBER\t|DOB\t\t|FEE\t|STUDY\t|ADDRESS\t|");
System.out.println("____________");
for(Details d : sdnt){
System.out.println("|"+d.rollnumber+
"\t|"+d.name+
"\t|"+d.gender+
"\t|"+d.aadharnumber+
"\t|"+d.DOB+
"\t|"+d.fee+
"\t|"+d.yearOfStudy+
"\t\t|"+d.address+"\t\t|");
System.out.println("____________");
}
break;
case 4 :
System.out.println("Enter the Student Roll number : ");
s_rn = sc.nextInt();
for(Details d : sdnt){
if(s_rn == d.rollnumber){
System.out.println("Menu");
System.out.println("1.Name\n2.Gender\n3.Aadhar Number\n4.DOB\n5.Fee\n6.Years Of Study\7.Address");
System.out.print("Enter the option that you want to edit : ");
int opt = sc.nextInt();
String a;
int b;
long c;
switch(opt){
case 1:
System.out.print("Enter the updated name : ");
a = sc.next();
d.name = a;
break;
case 2:
System.out.print("Enter the updated Gender : ");
a = sc.next();
d.gender = a;
break;
case 3:
System.out.print("Enter the updated Aadhar number : ");
c = sc.nextLong();
d.aadharnumber = c;
break;
case 4:
System.out.print("Enter the updated DOB : ");
a = sc.next();
d.DOB = a;
break;
case 5:
System.out.print("Enter the updated Fee : ");
b = sc.nextInt();
d.fee = b;
break;
case 6:
System.out.print("Enter the updated Years of Study : ");
b = sc.nextInt();
d.yearOfStudy = b;
break;
case 7:
System.out.print("Enter the updated Address : ");
a = sc.next();
d.address = a;
break;
}
flag = true;
break;
}
}
if(!flag){
System.out.println("Incorrect Roll number, PLEASE ENTER CORRECT ROLL NUMBER ");
}
break;
case 5 :
System.out.print("Enter the Student roll number to be deleted : ");
s_rn = sc.nextInt();
co = 0;
for(Details d : sdnt){
if(s_rn == d.rollnumber ){
sdnt.remove(d);
count--;
flag = true;
break;
}
}
if(!flag){
System.out.println("Incorrect Roll number, PLEASE ENTER CORRECT ROLL NUMBER ");
}else{
System.out.println("Student Details deleted successfully");
}
break;
case 6 :
f = false;
break;
default:
System.out.println("Enter the correct option from the menu");
}
}
}
}