├── Kavi.class └── Kavi.java /Kavi.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/K4VI12/Marks-Management-System/41ce28b24343670d8fc58130704c5f393e11eff2/Kavi.class -------------------------------------------------------------------------------- /Kavi.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | public class Kavi{ 3 | 4 | public static void menu(String[][] student, int[][] marks) { 5 | Scanner input = new Scanner(System.in); 6 | for (int i=0; i<81; i++) 7 | { 8 | System.out.printf("-"); 9 | } 10 | 11 | System.out.printf("\n|\t\t\tWELCOME TO GDSE MARKS MANAGEMENT SYSTEM\t\t\t|\n"); 12 | for (int i=0; i<81; i++) 13 | { 14 | System.out.print("-"); 15 | } 16 | System.out.print("\n[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\t\t\t\t\n"); 17 | System.out.print("[5] Update Marks \t\t\t[6] Delete Student\n[7] Print Student Details\t\t[8] Print Student Ranks\n"); 18 | System.out.println("[9] Best in Programming Fundamentals\t[10] Best in Database Management System\n"); 19 | 20 | 21 | System.out.print('\n' + "Enter an option to continue > "); 22 | int option = input.nextInt(); 23 | 24 | 25 | 26 | switch (option){ 27 | case 1: 28 | add_New_Student(student, marks); 29 | break; 30 | case 2: 31 | add_New_Student_With_Marks(student, marks); 32 | break; 33 | case 3: 34 | add_Marks(student, marks); 35 | break; 36 | case 4: 37 | update_Student_Details(student, marks); 38 | break; 39 | case 5: 40 | update_Marks(student, marks); 41 | break; 42 | case 6: 43 | delete_Student(student, marks); 44 | break; 45 | case 7: 46 | print_Student_Details(student, marks); 47 | break; 48 | case 8: 49 | Print_Student_Ranks(student,marks); 50 | break; 51 | case 9: 52 | best_In_Programming_Fundamentals(student,marks); 53 | break; 54 | case 10: 55 | best_in_Database_Management_System(student,marks); 56 | break; 57 | default: 58 | System.out.println("\nWrong number\n"); 59 | menu(student, marks); 60 | 61 | 62 | } 63 | 64 | } 65 | 66 | public final static void clearConsole() { 67 | try { 68 | final String os = System.getProperty("os.name"); 69 | if (os.contains("Windows")) { 70 | new ProcessBuilder("cmd", "/c", "cls").inheritIO().start().waitFor(); 71 | } else { 72 | System.out.print("\033[H\033[2J"); 73 | System.out.flush(); 74 | } 75 | } catch (final Exception e) { 76 | e.printStackTrace(); 77 | // Handle any exceptions. 78 | } 79 | } 80 | 81 | public static int nextValues(String[][] student) {//__for next ______________________ 82 | int index = student.length; 83 | for (int i = 0; i < student.length; i++) { 84 | if (student[i][0] == null) { 85 | index = i; 86 | break; 87 | 88 | } 89 | 90 | } 91 | 92 | return index; 93 | } 94 | 95 | public static void add_New_Student(String[][] student, int[][] marks) { 96 | Scanner input = new Scanner(System.in); 97 | clearConsole(); 98 | System.out.println("-------------------------------------------------------------------------"); 99 | System.out.println("|\t\t\t\tADD NEW STUDENT\t\t\t\t|"); 100 | System.out.println("-------------------------------------------------------------------------"); 101 | 102 | int index = nextValues(student); 103 | 104 | L1: 105 | for (int i = index; i < student.length; i++) { 106 | index = nextValues(student); 107 | System.out.print("Enter student id \t: "); 108 | String id = input.nextLine(); 109 | 110 | for (int j = 0; j < student.length; j++) { 111 | if (id.equals(student[j][0])) { 112 | System.out.println("Already exist!"); 113 | i--; 114 | continue L1; 115 | } 116 | } 117 | student[index][0] = id; 118 | 119 | System.out.print("Enter student name \t: "); 120 | student[index][1] = input.nextLine(); 121 | System.out.print('\n' + "Student has been Successful.Do you want to add a new student( Y/N ) : "); 122 | String x = input.nextLine(); 123 | if (x.equals("N") | x.equals("n")) 124 | { 125 | menu(student, marks); 126 | } 127 | 128 | if (x.equals("Y") | x.equals("y")) 129 | { 130 | continue L1; 131 | 132 | }else if (x.equals("N") | x.equals("n")){ 133 | menu(student, marks); 134 | 135 | }else { 136 | System.out.print("Wrong option !\n "); 137 | continue L1; 138 | } 139 | } 140 | } 141 | 142 | public static void add_New_Student_With_Marks(String[][] student, int[][] marks) { 143 | clearConsole(); 144 | Scanner input = new Scanner(System.in); 145 | System.out.println("--------------------------------------------------------------------------"); 146 | System.out.println("| ADD NEW STUDENT WITH MARKS |"); 147 | System.out.println("--------------------------------------------------------------------------"); 148 | 149 | int index = nextValues(student); 150 | L1: 151 | for (int i = index; i < student.length; i++) { 152 | index = nextValues(student); 153 | System.out.print("Enter student id \t: "); 154 | String id = input.nextLine(); 155 | 156 | for (int j = 0; j < student.length; j++) { 157 | if (id.equals(student[j][0])) { 158 | System.out.println("Already exist!"); 159 | i--; 160 | continue L1; 161 | } 162 | } 163 | student[index][0] = id; 164 | System.out.print("Enter student name \t: "); 165 | student[index][1] = input.nextLine(); 166 | 167 | for (int x = index; ; x++) { 168 | System.out.print("Program fundamental marks : "); 169 | marks[x][0] = input.nextInt(); 170 | if (marks[x][0] < 0 | marks [x][0]>100) { 171 | System.out.println("Invalid marks please enter correct marks." + '\n'); 172 | 173 | } else 174 | break; 175 | } 176 | for (int x = index; ; x++) { 177 | System.out.print("Database management marks : "); 178 | marks[x][1] = input.nextInt(); 179 | if (marks[x][1] < 0 | marks[x][1]>100 ) 180 | { 181 | System.out.println("Invalid marks please enter correct marks." + '\n'); 182 | } else 183 | 184 | break; 185 | } 186 | System.out.print('\n' + "Student has been successfully added.Do you want to add a new student(Y/N): "); 187 | String x = input.next(); 188 | if (x.equals("N") | x.equals("n")) 189 | { 190 | menu(student, marks); 191 | 192 | }if (x.equals("Y") | x.equals("y")) 193 | add_New_Student_With_Marks(student, marks); 194 | 195 | else { 196 | System.out.print("Wrong option !\n "); 197 | continue L1; 198 | } 199 | } 200 | } 201 | 202 | public static void add_Marks(String[][] student,int [][]marks) {//____________Add Marks sub method______________ 203 | Scanner input = new Scanner(System.in); 204 | 205 | clearConsole(); 206 | System.out.println("--------------------------------------------------------------------------------"); 207 | System.out.println("| Add Marks |"); 208 | System.out.println("--------------------------------------------------------------------------------"); 209 | 210 | for (int h = 0; h < student.length; h++) { 211 | String check; 212 | int x = -1;//if 676 line x=0 ,condition true... 213 | for (int z = 0; z < student.length; z++) { 214 | System.out.print("Enter Student ID : "); 215 | String id = input.nextLine(); 216 | 217 | L3: 218 | for (int i = 0; i < student.length; i++) { 219 | if (id.equals(student[i][0]))//check id in all Array 220 | x = i;//if true assign i to x 221 | if (i == x) 222 | break L3; 223 | } 224 | if (x == -1) {//--->check (-) numbers 225 | System.out.print("Invalid Student ID.Do you want to Search again?(Y/N) : "); 226 | check = input.nextLine(); 227 | if (check.equals("Y") | check.equals("y")){ 228 | continue; 229 | } 230 | if (check.equals("N") | check.equals("n")){ 231 | menu(student, marks); 232 | } 233 | } else 234 | break; 235 | } 236 | System.out.println("Student Name : " + student[x][1]); 237 | if (marks[x][0] == 0 && marks[x][1] == 0) { 238 | System.out.println(); 239 | } else { 240 | System.out.println("programming Fundamental Marks : " + marks[x][0]); 241 | System.out.println("Database Management Marks : " + marks[x][1]); 242 | System.out.println('\n' + "This Student's have been already added."); 243 | System.out.println("If you want to update the marks.please use [4] Update Marks Option." + '\n'); 244 | System.out.print('\n' + "DO you want to add mark for another student? (Y/N) :"); 245 | String q = input.nextLine(); 246 | if (q.equals("Y") | q.equals("y")){ 247 | continue; 248 | }if (q.equals("N") | q.equals("n")){ 249 | 250 | menu(student, marks); 251 | } 252 | } 253 | 254 | for (int i = 0; ; i++) {//equls to while loop 255 | 256 | System.out.print("programming Fundamental Marks : "); 257 | marks[x][0] = input.nextInt(); 258 | //int t = marks[x][0]; 259 | if (marks[x][0] < 0 | marks[x][0]>100 ) { 260 | System.out.println("Invalid marks,please enter correct marks." + '\n'); 261 | } else { 262 | break; 263 | } 264 | } 265 | 266 | for (int i = 0; ; i++) { 267 | 268 | System.out.print("Database Management Marks : "); 269 | marks[x][1] = input.nextInt(); 270 | int t = marks[x][1]; 271 | if (t < 0) 272 | System.out.println("Invalid marks,please enter correct marks." + '\n'); 273 | else 274 | break; 275 | } 276 | 277 | System.out.print('\n' + "Student has been Successively.Do you want to add a new student( Y/N ) : "); 278 | String N = input.next(); 279 | if (N.equals("N")|N.equals("n")) { 280 | menu(student,marks); 281 | }if (N.equals("Y")|N.equals("y")) 282 | continue; 283 | } 284 | } 285 | 286 | public static void update_Student_Details(String[][] student, int[][] marks) { 287 | Scanner input = new Scanner(System.in); 288 | System.out.println("--------------------------------------------------------------------------------"); 289 | System.out.println("| UPDATE STUDENT DETAILS |"); 290 | System.out.println(" -------------------------------------------------------------------------------"); 291 | System.out.println(); 292 | 293 | L1: 294 | for (int i = 0; i < student.length; i++) { 295 | System.out.print("Enter student id :"); 296 | String id = input.nextLine(); 297 | int j = 0; 298 | for (; j < student.length; j++) { 299 | if (id.equals(student[j][0])) { 300 | break; 301 | 302 | } 303 | 304 | } 305 | System.out.print("Student name :"); 306 | System.out.print(student[j][1]); 307 | 308 | System.out.print(" \n Enter the new student name :"); 309 | student[j][1] = input.nextLine(); 310 | 311 | 312 | System.out.print('\n' + "Student has been added successfully,Do you want to add a new student(Y/N) : "); 313 | String N = input.nextLine(); 314 | if (N.equals("N") | N.equals("n")) { 315 | menu(student, marks); 316 | } 317 | if (N.equals("Y") | N.equals("y")) 318 | continue L1; 319 | } 320 | } 321 | 322 | public static void update_Marks(String[][] student, int[][] marks) {//_____Update Student Details________------------------------- 323 | Scanner input = new Scanner(System.in); 324 | clearConsole(); 325 | 326 | System.out.println("-------------------------------------------------------------------------------"); 327 | System.out.println("| Update Marks |"); 328 | System.out.println(" ------------------------------------------------------------------------------"); 329 | System.out.println(); 330 | 331 | L1: 332 | for (int i = 0; i < student.length; i++) { 333 | System.out.print("Enter Student ID : "); 334 | String id = input.nextLine(); 335 | int x = 0; 336 | for (; x < student.length; x++) { 337 | if (id.equals(student[x][0])) { 338 | break; 339 | 340 | } 341 | } 342 | 343 | System.out.print("Student Name : "); 344 | System.out.println(student[x][1] + '\n'); 345 | for (int n = 0; n < student.length; n++) { 346 | if (student[x][2] == null) { 347 | System.out.println("This Student's marks yet to be added"); 348 | 349 | System.out.print("Do you want to Update marks for anther student ( Y/N ) :"); 350 | String y = input.nextLine(); 351 | if (y.equals("N") | y.equals("n")) { 352 | 353 | menu(student, marks); 354 | } 355 | 356 | if (y.equals("Y") | y.equals("y")) { 357 | continue L1; 358 | 359 | 360 | } 361 | } 362 | 363 | System.out.print("programming fundamentals Marks : "); 364 | System.out.println(marks[x][0]); 365 | 366 | System.out.print("Database Management System Marks : "); 367 | System.out.println(marks[x][1] + '\n'); 368 | 369 | System.out.print("Enter new programming fundamentals Marks : "); 370 | marks[x][0] = input.nextInt(); 371 | 372 | System.out.print("Enter new Database Management System Marks : "); 373 | marks[x][1] = input.nextInt(); 374 | 375 | System.out.println('\n' + "Marks have been Updated Successively."); 376 | System.out.print("Do you want to Update marks for anther student ( Y/N ) : "); 377 | String y = input.nextLine(); 378 | if (y.equals("N") | y.equals("n")) { 379 | 380 | menu(student, marks); 381 | } 382 | 383 | if (y.equals("Y") | y.equals("y")) ; 384 | continue L1; 385 | 386 | 387 | } 388 | 389 | } 390 | } 391 | 392 | public static void delete_Student(String[][] student, int[][] marks) { 393 | Scanner input = new Scanner(System.in); 394 | clearConsole(); 395 | System.out.println("---------------------------------------------------------------------------"); 396 | System.out.println("| DELETE STUDENT |"); 397 | System.out.println("---------------------------------------------------------------------------"); 398 | System.out.println(); 399 | 400 | L1: 401 | for (int i = 0; i < student.length; i++) { 402 | 403 | System.out.print("Enter Student ID : "); 404 | String id = input.next(); 405 | 406 | int a = 0; 407 | int x = 0; 408 | for (; a < student.length; a++) { 409 | if (id.equals(student[a][0])) { 410 | x = a; 411 | 412 | student[x][1] = null; 413 | student[x][0] = null; 414 | marks[x][0] = 0; 415 | marks[x][1] = 0; 416 | 417 | 418 | System.out.println("Student has been deleted successfully "); 419 | System.out.println("Do you want to Delete another student ( Y/N ) : "); 420 | 421 | 422 | String y = input.nextLine(); 423 | if (y.equals("N") | y.equals("n")) { 424 | 425 | menu(student, marks); 426 | } else if (y.equals("Y") | y.equals("y")) ; 427 | continue L1; 428 | 429 | 430 | } 431 | 432 | 433 | } 434 | } 435 | } 436 | 437 | public static void print_Student_Details(String[][] student, int[][] marks) { 438 | Scanner input = new Scanner(System.in); 439 | clearConsole(); 440 | System.out.println("------------------------------------------------------------------------------"); 441 | System.out.println("| Print Student Details |"); 442 | System.out.println("-------------------------------------------------------------------------------"); 443 | System.out.println(); 444 | 445 | 446 | L1: 447 | for (int i = 0; i < student.length; i++) { 448 | System.out.print("Enter Student ID : "); 449 | String id = input.nextLine();//Enter Student ID 450 | 451 | 452 | int x = 0; 453 | L2: 454 | for (; x < student.length; x++) { 455 | if (id.equals(student[x][0])) { 456 | System.out.println("Student Name : " + student[x][1]); 457 | break L2; 458 | } 459 | } 460 | 461 | if (marks[x][0]==(0)){ 462 | System.out.println("Marks yet to be added"); 463 | } else{ 464 | int tot = 0; 465 | tot = (marks[x][0]) + (marks[x][1]);//total 466 | 467 | 468 | String[][] temp = rank(student,marks);//Calling Rank method 469 | int rank = 0; 470 | for (; rank < student.length; rank++) {//find Rank 471 | if (id.equals(temp[rank][0])) 472 | break; 473 | } 474 | double avg; 475 | System.out.println("--------------------------------------------------------------------"); 476 | System.out.printf("|programming fundamentals Marks | "); 477 | System.out.print(marks[x][0]); 478 | System.out.println(" |"); 479 | System.out.printf("|Database Management System Marks | "); 480 | System.out.print(marks[x][1]); 481 | System.out.println(" |"); 482 | System.out.printf("|Total Marks | "); 483 | System.out.print(tot); 484 | System.out.println(" |"); 485 | System.out.printf("|Avg. Marks | "); 486 | System.out.print(avg = tot / 2); 487 | System.out.println(" |"); 488 | System.out.printf("|Rank | "); 489 | System.out.print(rank + 1); 490 | System.out.println(" |"); 491 | System.out.println("--------------------------------------------------------------------"); 492 | } 493 | 494 | System.out.print("Do you want to Search anther Student Details ( Y/N ) : ");//back to menu or this method 495 | String y = input.nextLine(); 496 | if (y.equals("N") | y.equals("n")) { 497 | menu(student, marks); 498 | } 499 | if (y.equals("Y") | y.equals("y")) ; 500 | continue L1; 501 | } 502 | } 503 | 504 | public static String[][] rank(String[][] student, int[][] marks) {//-------------------THIS METHOD USES BY RANK------------------------------------------- 505 | String temp[][] = new String[student.length][5]; 506 | int[] arr = new int[student.length]; 507 | 508 | for (int c = 0; c < temp.length; c++) { 509 | 510 | arr[c] = marks[c][0] + marks[c][1];//total 511 | 512 | 513 | 514 | temp[c][0] = student[c][0];//Copy ID 515 | temp[c][2] = student[c][1]; 516 | temp[c][3] = String.valueOf(arr[c] / 2); 517 | temp[c][1] = String.valueOf(arr[c]);// Copy total 518 | 519 | 520 | } 521 | 522 | 523 | String t; 524 | String h; 525 | String v; 526 | String a; 527 | for (int u = temp.length - 1; u > 0; u--) {//sort 528 | 529 | for (int j = 0; j < u; j++) 530 | 531 | if (Integer.parseInt(temp[j][1]) < Integer.parseInt(temp[j + 1][1])) { 532 | t = temp[j][1];//total 533 | temp[j][1] = temp[j + 1][1]; 534 | temp[j + 1][1] = t; 535 | 536 | h = temp[j][0];//ID 537 | temp[j][0] = temp[j + 1][0]; 538 | temp[j + 1][0] = h; 539 | 540 | v = temp[j][2];//Name 541 | temp[j][2] = temp[j + 1][2]; 542 | temp[j + 1][2] = v; 543 | 544 | a = temp[j][3];//avg 545 | temp[j][3] = temp[j + 1][3]; 546 | temp[j + 1][3] = a; 547 | } 548 | 549 | } 550 | return temp; 551 | } 552 | 553 | 554 | public static void Print_Student_Ranks(String[][] student, int[][] marks) {//------------------------Print_Student_Ranks---------------------------------- 555 | Scanner input = new Scanner(System.in); 556 | clearConsole(); 557 | System.out.println("-------------------------------------------------------------------------------"); 558 | System.out.println("| Print Student Ranks |"); 559 | System.out.println("-------------------------------------------------------------------------------"); 560 | System.out.println(); 561 | System.out.println("+-----------+------------+--------------------------+------------------+------------------"); 562 | System.out.printf("|"); 563 | System.out.printf("Rank"); 564 | System.out.printf(" |"); 565 | System.out.printf("ID"); 566 | System.out.printf(" |"); 567 | System.out.printf("Name"); 568 | System.out.printf(" |"); 569 | System.out.printf("Total Marks"); 570 | System.out.printf(" |"); 571 | System.out.printf("AVG. Marks"); 572 | System.out.println(" |"); 573 | 574 | System.out.println("+-----------+------------+--------------------------+------------------+------------------"); 575 | 576 | String[][] temp = rank(student, marks);//calling Rank method 577 | 578 | L1: 579 | for (int i = 0; i < student.length; i++) { 580 | 581 | if (student[i][0] == null) 582 | break L1; 583 | System.out.println("|" + (i + 1) + " |" + temp[i][0] + " |" + temp[i][2] + " |" + temp[i][1] + " |" + temp[i][3] + " |"); 584 | } 585 | 586 | System.out.println("+-----------+------------+--------------------------+------------------+------------------"); 587 | 588 | System.out.print("DO you want to go back to main menu (y/n) : "); 589 | String y = input.nextLine(); 590 | if (y.equals("Y") | y.equals("y")){ 591 | menu(student, marks); 592 | }else 593 | { 594 | clearConsole(); 595 | Print_Student_Ranks(student,marks); 596 | 597 | } 598 | } 599 | 600 | 601 | public static void best_In_Programming_Fundamentals(String[][] student,int [][] marks) { 602 | Scanner input = new Scanner(System.in); 603 | clearConsole(); 604 | 605 | int[] arr = new int[student.length]; 606 | for (int a = 0; a < student.length; a++) { 607 | arr[a] = marks[a][0]; 608 | 609 | 610 | String id; 611 | String name; 612 | int prf; 613 | int dbm; 614 | for (int u = student.length - 1; u > 0; u--) {//sort 615 | for (int j = 0; j < u; j++) 616 | if (arr[j] < arr[j + 1]) { 617 | id = student[j][0];//id 618 | student[j][0] = student[j + 1][0]; 619 | student[j + 1][0] = id; 620 | 621 | name = student[j][1];//name 622 | student[j][1] = student[j + 1][1]; 623 | student[j + 1][1] = name; 624 | 625 | prf = marks[j][0];//prf 626 | marks[j][0] = marks[j + 1][0]; 627 | marks[j + 1][0] = prf; 628 | 629 | dbm = marks[j][0];//dbm 630 | marks[j][1] = marks[j + 1][1]; 631 | marks[j + 1][1] = dbm; 632 | } 633 | } 634 | System.out.println("--------------------------------------------"); 635 | System.out.println("| Best In Programming Fundamentals |"); 636 | System.out.println("---------------------------------------------"); 637 | System.out.println(); 638 | System.out.println("+-----------+------------------------+------------------+------------------"); 639 | System.out.printf("|"); 640 | System.out.printf("ID"); 641 | System.out.printf(" |"); 642 | System.out.printf("Name"); 643 | System.out.printf(" |"); 644 | System.out.printf("PRF Marks"); 645 | System.out.printf(" |"); 646 | System.out.printf("DBM Marks"); 647 | System.out.println(" |"); 648 | 649 | System.out.println("+-----------+------------------------+------------------+------------------"); 650 | L1: 651 | for (int i = 0; i < student.length; i++) { 652 | 653 | if (student[i][0] == null) 654 | break L1; 655 | System.out.println("|" + student[i][0] + " |" + student[i][1] + " |" + marks[i][0] + " |" + marks[i][1] + " |"); 656 | } 657 | System.out.println("+-----------+------------------------+------------------+------------------"); 658 | 659 | 660 | System.out.print("DO you want to go back to main menu (Y/N) : "); 661 | String y = input.nextLine(); 662 | if ("Y".equals(y)) 663 | menu(student, marks); 664 | 665 | } 666 | } 667 | 668 | public static void best_in_Database_Management_System (String[][] student,int [][]marks) { 669 | Scanner input = new Scanner(System.in); 670 | clearConsole(); 671 | 672 | int []arr=new int[student.length]; 673 | for (int i=0;i 0; u--) {//sorting 685 | for (int j = 0; j < u; j++) 686 | if (arr[j]< arr[j+1]) { 687 | id = student[j][0];//id 688 | student[j][0] = student[j + 1][0]; 689 | student[j + 1][0] = id; 690 | 691 | name = student[j][1];//Name 692 | student[j][1] = student[j + 1][1]; 693 | student[j + 1][1] = name; 694 | 695 | prf= marks[j][0];//PRF 696 | marks[j][0] = marks[j + 1][0]; 697 | marks[j + 1][0] = prf; 698 | 699 | dbm = marks[j][1];//DBM 700 | marks[j][1] = marks[j + 1][1]; 701 | marks[j + 1][1] = dbm; 702 | } 703 | } 704 | System.out.println("-------------------------------------------------------------------------------"); 705 | System.out.println("| Best in Database Management System |"); 706 | System.out.println(" ------------------------------------------------------------------------------"); 707 | System.out.println(); 708 | System.out.println("+-----------+------------------------+------------------+------------------"); 709 | System.out.printf("|"); 710 | System.out.printf("ID"); 711 | System.out.printf(" |"); 712 | System.out.printf("Name"); 713 | System.out.printf(" |"); 714 | System.out.printf("PRF Marks"); 715 | System.out.printf(" |"); 716 | System.out.printf("DBM Marks"); 717 | System.out.println(" |"); 718 | 719 | System.out.println("+-----------+------------------------+------------------+------------------"); 720 | L1:for (int i=0;i