-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGDSE_MMS.java
More file actions
667 lines (606 loc) · 24.8 KB
/
GDSE_MMS.java
File metadata and controls
667 lines (606 loc) · 24.8 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
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
import java.util.*;
import java.lang.*;
class GDSE_MMS{
public static void main(String[] args) {
clearConsole();
titleBar("WELCOME TO GDSE MARK MANAGEMENT SYSTEM");
welcomePage();
int st_count=noOfStu();
String[] stId=new String[st_count]; String[] stName=new String[st_count]; // Decleration of arrays for store info
int[] stPfMarks=new int[st_count]; int[] stDbMarks=new int[st_count]; //marks arrays
int[] stTotalM=new int[st_count]; double[] stAvgM=new double[st_count];
int[] ar=new int[1]; //use for count variable
selectOption(stId,stName,stPfMarks,stDbMarks,ar,stTotalM,stAvgM);
return;
}
public static void selectOption(String[] stId,String[] stName,int[] stPfMarks,int[] stDbMarks,int[] ar,
int[] stTotalM,double[] stAvgM){
boolean b=true;
mainWhile :
do{
clearConsole();
titleBar("WELCOME TO GDSE MARK MANAGEMENT SYSTEM");
welcomePage();
int op=enterOption();
switch(op){
case 1 :
clearConsole();
titleBar("\tADD NEW STUDENT\t\t");
addNewStu(stId,stName,stPfMarks,stDbMarks,ar,stTotalM,stAvgM);
break;
case 2 :
clearConsole();
titleBar(" ADD NEW STUDENT WITH MARKS\t");
addStuWithMarks(stId,stName,stPfMarks,stDbMarks,ar,stTotalM,stAvgM);
break;
case 3 :
clearConsole();
titleBar("\t ADD MARKS\t\t");
addMarks(stId,stName,stPfMarks,stDbMarks,ar,stTotalM,stAvgM);
break;
case 4 :
clearConsole();
titleBar(" UPDATE STUDENT DETAILS\t");
updateStuDetails(stId,stName,stPfMarks,stDbMarks,ar,stTotalM,stAvgM);
break;
case 5 :
clearConsole();
titleBar("\t UPDATE MARKS\t\t");
updateMarks(stId,stName,stPfMarks,stDbMarks,ar,stTotalM,stAvgM);
break;
case 6 :
clearConsole();
titleBar("\t DELETE STUDENT\t\t");
deleteStu(stId,stName,stPfMarks,stDbMarks,ar,stTotalM,stAvgM);
break;
case 7 :
clearConsole();
titleBar(" PRINT STUDENT DETAILS\t");
printStudentDetails(stId,stName,stPfMarks,stDbMarks,ar,stTotalM,stAvgM);
break;
case 8 :
clearConsole();
titleBar(" PRINT STUDENT RANKS\t\t");
printStudentRanks(stId,stName,stPfMarks,stDbMarks,ar,stTotalM,stAvgM);
break;
case 9 :
clearConsole();
titleBar(" BEST IN PROGRAMMING FUNDEMENTALS");
printBestPf(stId,stName,stPfMarks,stDbMarks,ar,stTotalM,stAvgM);
break;
case 10 :
clearConsole();
titleBar("BEST IN DATABASE MANAGEMENT SYSTEM");
printBestDb(stId,stName,stPfMarks,stDbMarks,ar,stTotalM,stAvgM);
break;
default :
Scanner inputEx=new Scanner(System.in);
clearConsole();
titleBar("WELCOME TO GDSE MARK MANAGEMENT SYSTEM");
welcomePage();
System.out.print("\nDo you want to exit From the Application..(Y/N) ? ");
String ex=inputEx.nextLine();
if (ex.equals("y") || ex.equals("Y")) {
System.out.print("Bye,Have a Nice Day...!\n");
System.exit(0);
}
}
}while(b);
return;
}
public static void titleBar(String title){
System.out.println(
"+-------------------------------------------------------------------------------+\n"+
"|\t\t\t"+title+"\t\t\t|\n"+
"+-------------------------------------------------------------------------------+"
);
}
public static void welcomePage(){
System.out.println(
"[1] Add New Student\t\t\t [2] Add New Student With Marks\n"+
"[3] Add Marks\t\t\t\t [4] Update Student Details\n"+
"[5] Update Marks\t\t\t [6] Delete Student\n"+
"[7] Print Student Details\t\t [8] Print Student Ranks\n"+
"[9] Best in Programming Fundementals\t [10] Best in Database Management System"
);
}
public static int noOfStu(){ //I can't declare array size without input. array size auto increment ??
Scanner input=new Scanner(System.in);
System.out.print("\nHow many students are expected to attend the course ? : ");
return (input.nextInt());
}
public static int enterOption(){
Scanner input=new Scanner(System.in);
System.out.println("\nIf you want to exit,Enter another number...");
System.out.print("Enter an option to continue > ");
return(input.nextInt());
}
public static void selectYN(String line,String ynMsg,String[] stId,String[] stName,int[] stPfMarks,int[] stDbMarks,int[] ar,
int[] stTotalM,double[] stAvgM){
Scanner input=new Scanner(System.in);
System.out.print(line);
String x=input.nextLine();
if (x.equals("Y") || x.equals("y")) {
clearConsole();
return;
}
else if(x.equals("N") || x.equals("n")){
clearConsole();
selectOption(stId,stName,stPfMarks,stDbMarks,ar,stTotalM,stAvgM);
}
else{
line="Invalid input..! Please Enter Y or N .. \n\n"+ynMsg;
selectYN(line,ynMsg,stId,stName,stPfMarks,stDbMarks,ar,stTotalM,stAvgM);
}
}
public static void addNewStu(String[] stId,String[] stName,int[] stPfMarks,int[] stDbMarks,int[] ar,
int[] stTotalM,double[] stAvgM){ //[1] add new st
Scanner input=new Scanner(System.in);
outerLoop: //Add Label
for (int i=ar[0];i<stId.length ;i++ ) {
System.out.print("Enter Student ID\t: ");
String id=input.nextLine();
for(String j:stId){
if (id.equals(j)) {
i--;
System.out.println("The Student ID already Exists..\n");
continue outerLoop;
}
}
stId[i]=id;
System.out.print("Enter Student Name\t: ");
stName[i]=input.nextLine();
stPfMarks[i]=-1; stDbMarks[i]=-1; // make a chance for enter 0 mark
ar[0]++;
selectYN("\nStudent has been added Successfully.. Do you want to add a new student (Y/N) : ",
"Do you want to add a new student (Y/N) :",stId,stName,stPfMarks,stDbMarks,ar,stTotalM,stAvgM);
titleBar("\tADD NEW STUDENT\t\t");
continue outerLoop;
}
return;
}
public static void addStuWithMarks(String[] stId,String[] stName,int[] stPfMarks,int[] stDbMarks,int[] ar,
int[] stTotalM,double[] stAvgM){ // [2] add new st with mark
Scanner input=new Scanner(System.in);
outerLoop: //Add Label
for (int i=ar[0];i<stId.length ;i++ ) {
System.out.print("Enter Student ID\t: ");
String iq=input.nextLine();
for(String j:stId){
if (iq.equals(j)) {
i--;
System.out.println("The Student ID already Exists..\n");
continue outerLoop;
}
}
stId[i]=iq;
System.out.print("Enter Student Name\t: ");
stName[i]=input.nextLine();
{// start of add marks-----------------
boolean b=true;
do{
System.out.print("\nEnter Programming Fundemental Mark\t: ");
int mp=input.nextInt();
if (mp<0 || mp>100){
System.out.println("Invalid mark,Please Enter correct mark.. ");
continue;
}else{
stPfMarks[i]=mp;
b=false;
}
}while(b);
b=true;
do{
System.out.print("Enter Database Management System Mark\t: ");
int md=input.nextInt();
if (md<0 || md>100){
System.out.println("\nInvalid mark,Please Enter correct mark.. ");
continue;
}else{
stDbMarks[i]=md;
b=false;
}
}while(b);
}// end of add marks-----------------
ar[0]++;
selectYN("\nStudent has been added Successfully.. Do you want to add a new student (Y/N) : ",
"Do you want to add a new student (Y/N) :",stId,stName,stPfMarks,stDbMarks,ar,stTotalM,stAvgM);
titleBar(" ADD NEW STUDENT WITH MARKS\t");
addStuWithMarks(stId,stName,stPfMarks,stDbMarks,ar,stTotalM,stAvgM);
}
return ;
}
public static void addMarks(String[] stId,String[] stName,int[] stPfMarks,int[] stDbMarks,int[] ar,
int[] stTotalM,double[] stAvgM){
Scanner input=new Scanner(System.in);
outerLoop: //Add Label
for (int k=0;k<stId.length ;k++ ) {
System.out.print("Enter Student ID\t: ");
String im=input.nextLine();
if (checkValidId(stId,im,ar)) {
System.out.print("Invalid Student ID. Do you want to Search Again(Y/N) ? ");
String x=input.nextLine();
if (x.equals("Y") || x.equals("y")) {
clearConsole();
titleBar("\t ADD MARKS\t\t");
addMarks(stId,stName,stPfMarks,stDbMarks,ar,stTotalM,stAvgM);
}else {
clearConsole();
selectOption(stId,stName,stPfMarks,stDbMarks,ar,stTotalM,stAvgM);
}
}else{
int index=checkMatchingIndex(stId,im,ar);
if(stPfMarks[index]!=-1){
System.out.println("Student Name\t\t: "+stName[index]);
System.out.println("This student's marks have been already added.."+
"\nIf you want to update the marks. Please use [5] Update Marks Option.");
selectYN("\nDo you want to add marks for another Student (Y/N) : ",
"Do you want to add marks for another Student (Y/N) : ",stId,stName,stPfMarks,stDbMarks,ar,stTotalM,stAvgM);
clearConsole();
titleBar("\t ADD MARKS\t\t");
addMarks(stId,stName,stPfMarks,stDbMarks,ar,stTotalM,stAvgM);
}
if (index>=0) {
System.out.println("Student Name\t\t: "+stName[index]);
{//start of add marks-----------------
boolean b=true;
do{
System.out.print("\nEnter Programming Fundemental Mark\t: ");
int mp=input.nextInt();
if (mp<0 || mp>100){
System.out.println("Invalid mark,Please Enter correct mark.. ");
continue;
}else{
stPfMarks[index]=mp;
b=false;
}
}while(b);
b=true;
do{
System.out.print("Enter Database Management System Mark\t: ");
int md=input.nextInt();
if (md<0 || md>100){
System.out.println("\nInvalid mark,Please Enter correct mark.. ");
continue;
}else{
stDbMarks[index]=md;
b=false;
}
}while(b);
}// end of add marks-----------------
}
}
selectYN("\nMarks has been added Successfully... Do you want to add marks for another Student (Y/N) : ",
"Do you want to add marks for another Student (Y/N) : ",stId,stName,stPfMarks,stDbMarks,ar,stTotalM,stAvgM);
titleBar("\t ADD MARKS\t\t");
addMarks(stId,stName,stPfMarks,stDbMarks,ar,stTotalM,stAvgM);
}
return;
}
public static void updateStuDetails(String[] stId,String[] stName,int[] stPfMarks,int[] stDbMarks,int[] ar,
int[] stTotalM,double[] stAvgM){
Scanner input=new Scanner(System.in);
for (int i=0;i<stId.length ;i++ ) {
System.out.print("Enter Student ID\t: ");
String im=input.nextLine();
if (checkValidId(stId,im,ar)) {
System.out.print("Invalid Student ID. Do you want to Search Again(Y/N) ? ");
String x=input.nextLine();
if (x.equals("Y") || x.equals("y")) {
clearConsole();
titleBar(" UPDATE STUDENT DETAILS\t");
updateStuDetails(stId,stName,stPfMarks,stDbMarks,ar,stTotalM,stAvgM);
}else {
clearConsole();
selectOption(stId,stName,stPfMarks,stDbMarks,ar,stTotalM,stAvgM);
}
}else {
int index=checkMatchingIndex(stId,im,ar);
System.out.println("Student Name\t\t: "+stName[index]+"\n");
System.out.print("Enter the new Student Name : ");
stName[index]=input.nextLine();
selectYN("\nStudent Details has been updated Successfully.. Do you want to update another Student Details (Y/N) : ",
"Do you want to update another Student Details (Y/N) : ",stId,stName,stPfMarks,stDbMarks,ar,stTotalM,stAvgM);
titleBar(" UPDATE STUDENT DETAILS\t");
updateStuDetails(stId,stName,stPfMarks,stDbMarks,ar,stTotalM,stAvgM);
}
}
return;
}
public static void updateMarks(String[] stId,String[] stName,int[] stPfMarks,int[] stDbMarks,int[] ar,
int[] stTotalM,double[] stAvgM){
Scanner input=new Scanner(System.in);
for (int i=0;i<stId.length ;i++ ) {
System.out.print("Enter Student ID\t: ");
String im=input.nextLine();
if (checkValidId(stId,im,ar)) {
System.out.print("Invalid Student ID. Do you want to Search Again(Y/N) ? ");
String x=input.nextLine();
if (x.equals("Y") || x.equals("y")) {
clearConsole();
titleBar("\t UPDATE MARKS\t\t");
updateMarks(stId,stName,stPfMarks,stDbMarks,ar,stTotalM,stAvgM);
}else {
clearConsole();
selectOption(stId,stName,stPfMarks,stDbMarks,ar,stTotalM,stAvgM);
}
}else {
int index=checkMatchingIndex(stId,im,ar);
if (stPfMarks[index]!=-1) {
System.out.println("Student Name\t\t: "+stName[index]+"\n");
System.out.println("Programming Fundemental Mark\t: "+stPfMarks[index]);
System.out.println("Database Management System Mark\t: "+stPfMarks[index]+"\n");
System.out.print("Enter new Programming Fundemental Mark\t\t: ");
stPfMarks[index]=input.nextInt();
System.out.print("Enter new Database Management System Mark\t: ");
stDbMarks[index]=input.nextInt();
selectYN("\nMarks has been updated Successfully.. Do you want to update Marks for another Student (Y/N) : ",
"Do you want to update Marks for another Student (Y/N) : ",stId,stName,stPfMarks,stDbMarks,ar,stTotalM,stAvgM);
titleBar("\t UPDATE MARKS\t\t");
updateMarks(stId,stName,stPfMarks,stDbMarks,ar,stTotalM,stAvgM);
}else{
System.out.println("Student Name\t\t: "+stName[index]+"\n");
System.out.println("This Student's marks yet to be added..");
selectYN("Do you want to update Marks for another Student (Y/N) : ",
"",stId,stName,stPfMarks,stDbMarks,ar,stTotalM,stAvgM);
titleBar("\t UPDATE MARKS\t\t");
updateMarks(stId,stName,stPfMarks,stDbMarks,ar,stTotalM,stAvgM);
}
}
}
return;
}
public static void deleteStu(String[] stId,String[] stName,int[] stPfMarks,int[] stDbMarks,int[] ar,
int[] stTotalM,double[] stAvgM){
Scanner input=new Scanner(System.in);
for (int i=0;i<stId.length ;i++ ) {
System.out.print("Enter Student ID\t: ");
String im=input.nextLine();
if (checkValidId(stId,im,ar)) {
System.out.print("Invalid Student ID. Do you want to Search Again(Y/N) ? ");
String x=input.nextLine();
if (x.equals("Y") || x.equals("y")) {
clearConsole();
titleBar("\t DELETE STUDENT\t\t");
deleteStu(stId,stName,stPfMarks,stDbMarks,ar,stTotalM,stAvgM);
}else {
clearConsole();
selectOption(stId,stName,stPfMarks,stDbMarks,ar,stTotalM,stAvgM);
}
}else {
int index=checkMatchingIndex(stId,im,ar);
System.out.println("Student Name\t\t: "+stName[index]+"\n");
System.out.println("Programming Fundemental Mark\t: "+/*stPfMarks[index]==-1 ? "marks not added":*/stPfMarks[index]);
System.out.println("Database Management System Mark\t: "+/*stPfMarks[index]==-1 ? "marks not added" : */stDbMarks[index]+"\n");
if (stPfMarks[index]<0) {
System.out.println("If mark is (-1),That Student's marks not added yet..!");
}
stId[index]="null"; stName[index]="null"; stPfMarks[index]=-1; stDbMarks[index]=-1;
stTotalM[index]=-1; stAvgM[index]=0;
selectYN("\nAbove Student has been delete Successfully.. Do you want to delete another Student (Y/N) : ",
"Do you want to delete another Student (Y/N) : ",stId,stName,stPfMarks,stDbMarks,ar,stTotalM,stAvgM);
titleBar("\t DELETE STUDENT\t\t");
deleteStu(stId,stName,stPfMarks,stDbMarks,ar,stTotalM,stAvgM);
}
}
return;
}
public static void printStudentDetails(String[] stId,String[] stName,int[] stPfMarks,int[] stDbMarks,int[] ar,
int[] stTotalM,double[] stAvgM){
Scanner input=new Scanner(System.in);
stTotalM=createTotalMarks(stPfMarks,stDbMarks,stTotalM,ar);
stAvgM=createAvgMarks(stPfMarks,stDbMarks,stAvgM,ar);
sortingTotalForRanks(stId,stName,stPfMarks,stDbMarks,ar,stTotalM,stAvgM);
for (int i=0;i<stId.length ;i++ ) {
System.out.print("Enter Student ID\t: ");
String im=input.nextLine();
if (checkValidId(stId,im,ar)) {
System.out.print("Invalid Student ID. Do you want to Search Again(Y/N) ? ");
String x=input.nextLine();
if (x.equals("Y") || x.equals("y")) {
clearConsole();
titleBar(" PRINT STUDENT DETAILS\t");
printStudentDetails(stId,stName,stPfMarks,stDbMarks,ar,stTotalM,stAvgM);
}else {
clearConsole();
selectOption(stId,stName,stPfMarks,stDbMarks,ar,stTotalM,stAvgM);
}
}else {
int index=checkMatchingIndex(stId,im,ar);
if (stPfMarks[index]!=-1) {
int ind=index+1; String place="";
switch(ind){
case 1: place=" (First)"; break;
case 2: place=" (Second)"; break;
case 3: place=" (Third)"; break;
case 4: place=" (Fourth)"; break;
case 5: place=" (Fifth)"; break;
default :place=" (Above 5th)"; break;
}
System.out.println("Student Name\t\t: "+stName[index]+"\n");
System.out.printf("+%-44s+%15s+%n","--------------------------------------------","---------------");
System.out.printf("|%-44s|%15d|%n" ,"Programming Fundamentals Marks" ,stPfMarks[index]);
System.out.printf("|%-44s|%15d|%n" ,"Database Management Systems Marks" ,stDbMarks[index]);
System.out.printf("|%-44s|%15d|%n" ,"Total Marks" ,stTotalM[index]);
System.out.printf("|%-44s|%15.2f|%n" ,"Average Marks" ,stAvgM[index]);
System.out.printf("|%-44s|%15s|%n" ,"Rank" ,(ind+place));
System.out.printf("+%-44s+%15s+%n","--------------------------------------------","---------------");
}else{
System.out.println("Student Name\t\t: "+stName[index]+"\n");
System.out.println("Mark yet to be added..Do you want to add Mark for this student,use [3] Add Mark option");
selectYN("\nDo you want to Search another Student Details (Y/N) : ","",stId,stName,stPfMarks,stDbMarks,ar,stTotalM,stAvgM);
titleBar(" PRINT STUDENT DETAILS\t");
printStudentDetails(stId,stName,stPfMarks,stDbMarks,ar,stTotalM,stAvgM);
}
selectYN("\nDo you want to Search another Student Details (Y/N) : ","",stId,stName,stPfMarks,stDbMarks,ar,stTotalM,stAvgM);
titleBar(" PRINT STUDENT DETAILS\t");
printStudentDetails(stId,stName,stPfMarks,stDbMarks,ar,stTotalM,stAvgM);
}
}
return;
}
public static void printStudentRanks(String[] stId,String[] stName,int[] stPfMarks,int[] stDbMarks,int[] ar,
int[] stTotalM,double[] stAvgM){
stTotalM=createTotalMarks(stPfMarks,stDbMarks,stTotalM,ar);
stAvgM=createAvgMarks(stPfMarks,stDbMarks,stAvgM,ar);
sortingTotalForRanks(stId,stName,stPfMarks,stDbMarks,ar,stTotalM,stAvgM);
System.out.printf("+%-10s+%-10s+%-15s+%-15s+%-15s+%n","----------","----------","---------------","---------------","---------------");
System.out.printf("|%-10s|%-10s|%-15s|%-15s|%-15s|%n", "Rank", "ID", "Name", "Total Marks", "Avg.Marks");
System.out.printf("+%-10s+%-10s+%-15s+%-15s+%-15s+%n","----------","----------","---------------","---------------","---------------");
for (int i=0;i<ar[0] ;i++ ) {
if (stPfMarks[i]<0) {
continue;
}
System.out.printf("|%-10d|%-10s|%-15s|%-15d|%-15.2f|%n",(i+1),stId[i], stName[i], stTotalM[i], stAvgM[i]);
}
System.out.printf("+%-10s+%-10s+%-15s+%-15s+%-15s+%n","----------","----------","---------------","---------------","---------------");
selectYN("\nDo you want to stay more time (Y/N) : ","",stId,stName,stPfMarks,stDbMarks,ar,stTotalM,stAvgM);
titleBar(" PRINT STUDENT RANKS\t\t");
printStudentRanks(stId,stName,stPfMarks,stDbMarks,ar,stTotalM,stAvgM);
}
public static void printBestPf(String[] stId,String[] stName,int[] stPfMarks,int[] stDbMarks,int[] ar,
int[] stTotalM,double[] stAvgM){
stTotalM=createTotalMarks(stPfMarks,stDbMarks,stTotalM,ar);
stAvgM=createAvgMarks(stPfMarks,stDbMarks,stAvgM,ar);
sortingPfForBestPf(stId,stName,stPfMarks,stDbMarks,ar);
System.out.printf("+%-10s+%-15s+%-15s+%-15s+%n","----------","---------------","---------------","---------------");
System.out.printf("|%-10s|%-15s|%-15s|%-15s|%n","ID", "Name", "PF Marks Marks", "DBMS Marks");
System.out.printf("+%-10s+%-15s+%-15s+%-15s+%n","----------","---------------","---------------","---------------");
for (int i=0;i<ar[0] ;i++ ) {
if (stPfMarks[i]<0) {
continue;
}
System.out.printf("|%-10s|%-15s|%-15d|%-15d|%n",stId[i], stName[i], stPfMarks[i], stDbMarks[i]);
}
System.out.printf("+%-10s+%-15s+%-15s+%-15s+%n","----------","---------------","---------------","---------------");
selectYN("\nDo you want to stay more time (Y/N) : ","",stId,stName,stPfMarks,stDbMarks,ar,stTotalM,stAvgM);
titleBar(" BEST IN PROGRAMMING FUNDEMENTALS");
printBestPf(stId,stName,stPfMarks,stDbMarks,ar,stTotalM,stAvgM);
}
public static void printBestDb(String[] stId,String[] stName,int[] stPfMarks,int[] stDbMarks,int[] ar,
int[] stTotalM,double[] stAvgM){
stTotalM=createTotalMarks(stPfMarks,stDbMarks,stTotalM,ar);
stAvgM=createAvgMarks(stPfMarks,stDbMarks,stAvgM,ar);
sortingDbForBestDb(stId,stName,stPfMarks,stDbMarks,ar);
System.out.printf("+%-10s+%-15s+%-15s+%-15s+%n","----------","---------------","---------------","---------------");
System.out.printf("|%-10s|%-15s|%-15s|%-15s|%n","ID", "Name", "DBMS Marks", "PF Marks");
System.out.printf("+%-10s+%-15s+%-15s+%-15s+%n","----------","---------------","---------------","---------------");
for (int i=0;i<ar[0] ;i++ ) {
if (stDbMarks[i]<0) {
continue;
}
System.out.printf("|%-10s|%-15s|%-15d|%-15d|%n",stId[i], stName[i], stDbMarks[i], stPfMarks[i]);
}
System.out.printf("+%-10s+%-15s+%-15s+%-15s+%n","----------","---------------","---------------","---------------");
selectYN("\nDo you want to stay more time (Y/N) : ","",stId,stName,stPfMarks,stDbMarks,ar,stTotalM,stAvgM);
titleBar("BEST IN DATABASE MANAGEMENT SYSTEM");
printBestDb(stId,stName,stPfMarks,stDbMarks,ar,stTotalM,stAvgM);
}
public static int[] createTotalMarks(int[] stPfMarks,int[] stDbMarks,int[] stTotalM,int[] ar){
for (int i=0;i<ar[0] ;i++ ) {
stTotalM[i]=stPfMarks[i]+stDbMarks[i];
}
return stTotalM;
}
public static double[] createAvgMarks(int[] stPfMarks,int[] stDbMarks,double[] stAvgM,int[] ar){
for (int i=0;i<ar[0] ;i++ ) {
stAvgM[i]=(double)((stPfMarks[i]+stDbMarks[i])/2);
}
return stAvgM;
}
public static void sortingTotalForRanks(String[] stId,String[] stName,int[] stPfMarks,int[] stDbMarks,int[] ar,
int[] stTotalM,double[] stAvgM){
for(int j=ar[0]-1; j>=0;j--){
for(int i=0;i<j; i++){
if(stTotalM[i]<stTotalM[i+1]){
int t=stTotalM[i];
stTotalM[i]=stTotalM[i+1];
stTotalM[i+1]=t;
String t1=stId[i];
stId[i]=stId[i+1];
stId[i+1]=t1;
String t2=stName[i];
stName[i]=stName[i+1];
stName[i+1]=t2;
int t3=stPfMarks[i];
stPfMarks[i]=stPfMarks[i+1];
stPfMarks[i+1]=t3;
int t4=stDbMarks[i];
stDbMarks[i]=stDbMarks[i+1];
stDbMarks[i+1]=t4;
double t5=stAvgM[i];
stAvgM[i]=stAvgM[i+1];
stAvgM[i+1]=t5;
}
}
}
}
public static void sortingPfForBestPf(String[] stId,String[] stName,int[] stPfMarks,int[] stDbMarks,int[] ar){
for(int j=ar[0]-1; j>=0;j--){
for(int i=0;i<j; i++){
if(stPfMarks[i]<stPfMarks[i+1]){
int t=stPfMarks[i];
stPfMarks[i]=stPfMarks[i+1];
stPfMarks[i+1]=t;
String t1=stId[i];
stId[i]=stId[i+1];
stId[i+1]=t1;
String t2=stName[i];
stName[i]=stName[i+1];
stName[i+1]=t2;
int t4=stDbMarks[i];
stDbMarks[i]=stDbMarks[i+1];
stDbMarks[i+1]=t4;
}
}
}
}
public static void sortingDbForBestDb(String[] stId,String[] stName,int[] stPfMarks,int[] stDbMarks,int[] ar){
for(int j=ar[0]-1; j>=0;j--){
for(int i=0;i<j; i++){
if(stDbMarks[i]<stDbMarks[i+1]){
int t=stDbMarks[i];
stDbMarks[i]=stDbMarks[i+1];
stDbMarks[i+1]=t;
String t1=stId[i];
stId[i]=stId[i+1];
stId[i+1]=t1;
String t2=stName[i];
stName[i]=stName[i+1];
stName[i+1]=t2;
int t3=stPfMarks[i];
stPfMarks[i]=stPfMarks[i+1];
stPfMarks[i+1]=t3;
}
}
}
}
public static int checkMatchingIndex(String[] stId,String im,int[] ar){
int index=-1;
for (int j=0;j<ar[0] ;j++ ) {
index=im.equals( stId[j]) ? j: index;
}
return index;
}
public static boolean checkValidId(String[] stId,String id,int[] ar){
for(int i=0;i<ar[0];i++){
if(stId[i].equals(id))
return false;
}
return true;
}
public final static void clearConsole() {
try {
final String os = System.getProperty("os.name");
if (os.contains("Windows")) {
new ProcessBuilder("cmd", "/c", "cls").inheritIO().start().waitFor();
} else {
System.out.print("\033[H\033[2J");
System.out.flush();
}
} catch (final Exception e) {
e.printStackTrace();
// Handle any exceptions.
}
}
}