Java student information management system source code, student information management system

Source: Internet
Author: User

Java student information management system source code, student information management system

The examples in this article share with you the specific code of the java student information management system to implement student information: Add int [] a = new int [9], delete, search, and change for your reference, the details are as follows:

/* Student information management system to implement student information: * Add int [] a = new int [9] * Delete * search * change */import java. util. imports; // import the java input stream import java. lang. *; import java. io. *; class Student {private static Student [] s = new Student [2]; int n = 0; private String name; private int num; private String classAge; public void judge () throws IOException {int I; char ch; String str; exist In = new expect (System. in); if (n = 0) {System. out. print ("You have not entered Any student, whether to input (Y/N): "); str = In. next (); ch = str. charAt (0); while (ch! = 'Y' & ch! = 'Y' & ch! = 'N' & ch! = 'N') {System. out. print ("incorrect input. Please enter again:"); str = In. next (); ch = str. charAt (0);} if (ch = 'y' | ch = 'y') {this. add () ;}if (ch = 'n' | ch = 'n') {this. menu () ;}} public void menu () throws IOException // defines the menu function {int a; // defines the switch statement variable running in = new functions (System. in); // instantiate the input stream object System. out. println ("********** student information management System menu **********"); System. out. println ("***** 1. added ***** "); System. out. println ("***** 2. display *****"); System. out. println ("***** 3. modify *** "); System. out. println ("***** 4. delete ***** "); System. out. println ("***** 5. view ***** "); System. out. println ("***** 0. exit ***** "); System. out. println ("************************************* ***"); system. out. print ("select (0 ~ 5): "); a = in. nextInt (); while (a <0 | a> 5) {System. out. print ("the input is out of the range. Please enter it again:"); a = in. nextInt ();} switch (a) {case 1: this. add (); break; case 2: this. show (); break; case 3: this. modif (); break; case 4: this. delete (); break; case 5: this. look (); break; case 0: System. exit (0); break ;}} public void add () throws IOException // defines the add function {String str, str1, str2; int I, num1, t = 1; char ch, delimiter; FileWriter fw = new FileWriter ("F :/ /JavaFile // student.txt ", true); fw. write ("input student information list \ r \ n student ID name class \ r \ n"); student In = new student (System. in); while (t = 1) {System. out. print ("Enter the student ID:"); num1 = In. nextInt (); for (I = 0; I <n; I ++) {while (s [I]. num = num1) {System. out. println ("this student ID already exists, please enter it again"); System. out. print ("Enter your student ID:"); num1 = In. nextInt () ;}} s [n]. num = num1; str2 = String. valueOf (num1); fw. write (str2 + ""); System. out. println (); System. out. pr Int ("Enter the Student name:"); s [n]. name = In. next (); fw. write (s [n]. name + ""); System. out. println (); System. out. print ("Enter the student class:"); s [n]. classAge = In. next (); fw. write (s [n]. classAge + "\ r \ n"); ++ n; fw. close (); System. out. println (); System. out. print ("whether to add (Y/N)"); str = In. next (); ch = str. charAt (0); while (ch! = 'N' & ch! = 'N' & ch! = 'Y' & ch! = 'Y') {System. out. print ("incorrect input. Please enter again:"); str = In. next (); ch = str. charAt (0);} if (ch = 'n' | ch = 'n') {break;} System. out. println (); System. out. print ("whether to return to the main menu (Y/N)"); str1 = In. next (); character = str1.charAt (0); while (character! = 'Y' & found! = 'Y' & found! = 'N' & amp; success! = 'N') {System. out. print ("incorrect input, please enter again:"); str1 = In. next (); lower = str1.charAt (0);} if (lower = 'y' | Lower = 'y') {this. menu ();} if (records = 'n' | records = 'n') {System. out. println ("exiting... thank you! "); System. exit (0) ;}} public void show () throws IOException {int I; this. judge (); System. out. println ("Total number of students entered in this operation" + n +! "); System. out. println ("the student information you enter is as follows:"); System. out. println (); System. out. println ("student ID \ t name \ t class"); for (I = 0; I <n; I ++) {System. out. println (s [I]. num + "" + s [I]. name + "" + s [I]. classAge);} System. out. println ("the system returns to the main menu! "); This. menu ();} public void delete () throws IOException // information deletion function implementation Note: this function is not extensible for the moment {this. judge (); int j = 0, t = 0, k = 0, num1; char ch; String str; sort pin = new sort (System. in); System. out. print ("Enter the student ID to delete:"); num1 = pin. nextInt (); for (j = 0; j <n; j ++) {if (s [j]. num = num1) {k = 1; t = j ;}} if (k = 0) {System. out. println ("Sorry! The student ID you want to delete does not exist! "); System. out. println (" the System will return to the main menu! "); This. menu ();} if (k = 1) {System. out. println ("the student information you want to delete is as follows:"); // print the student information System the administrator wants to delete. out. println ("student ID \ t name \ t class"); // This function does not support extended System temporarily. out. println (s [t]. num + "" + s [t]. name + "" + s [t]. classAge); System. out. println (); System. out. print ("are you sure you want to delete (Y/N):"); str = pin. next (); ch = str. charAt (0); while (ch! = 'Y' & ch! = 'Y' & ch! = 'N' & ch! = 'N') {System. out. print ("incorrect input, please enter again:"); str = pin. next (); ch = str. charAt (0);} if (ch = 'n' | ch = 'n') {System. out. println (); System. out. println ("the system returns to the main menu! "); This. menu () ;}if (ch = 'y' | ch = 'y') {for (j = t; j <n-1; j ++) {s [j] = s [j + 1];} n --; System. out. println ("data deleted successfully! "); System. out. println (" the System returns to the main menu! "); This. menu () ;}} public void look () throws IOException {FileReader fr = new FileReader ("F: // javaFile // student.txt"); int; while (a = fr. read ())! =-1) {System. out. print (char) a);} fr. close (); System. out. println ("the System returns to the main menu! "); System. out. println (); this. menu ();} public void modif () throws IOException {this. judge (); int j = 0, t = 0, k = 0, num2, num3, moi, c = 1; char ch; String str, str1, str2; pin = new partition (System. in); System. out. print ("Enter the student ID to be modified:"); num2 = pin. nextInt (); for (j = 0; j <n; j ++) {if (s [j]. num = num2) {k = 1; t = j ;}} if (k = 0) {System. out. println ("Sorry! The student ID you want to modify does not exist! "); System. out. println (" the System will return to the main menu! "); This. menu ();} if (k = 1) {System. out. println ("the student information you want to modify is as follows:"); // print the student information System the administrator wants to delete. out. println ("student ID \ t name \ t class"); // This function does not support extended System temporarily. out. println (s [t]. num + "" + s [t]. name + "" + s [t]. classAge); System. out. println (); System. out. print ("are you sure you want to modify (Y/N):"); str = pin. next (); ch = str. charAt (0); while (ch! = 'Y' & ch! = 'Y' & ch! = 'N' & ch! = 'N') {System. out. print ("incorrect input, please enter again:"); str = pin. next (); ch = str. charAt (0);} if (ch = 'n' | ch = 'n') {System. out. println (); System. out. println ("the system returns to the main menu! "); This. menu ();} while (c = 1) {if (ch = 'y' | ch = 'y') {System. out. println ("************************************* ***"); system. out. println ("***** 1. modify student ID ***** "); System. out. println ("***** 2. modify the class ***** "); System. out. println ("***** 3. change name ***** "); System. out. println ("************************************* ***"); system. out. print ("select:"); moi = pin. nextInt (); switch (moi) {case 1: System. out. print ("enter a new student ID: "); Num3 = pin. nextInt (); s [t]. num = num3; break; case 2: System. out. print ("enter a new class:"); str1 = pin. next (); s [t]. classAge = str1; break; case 3: System. out. print ("enter a new name:"); str2 = pin. next (); s [t]. name = str2; break;} System. out. println ("data modified successfully! ");} System. out. print ("whether to continue modifying (Y/N)"); str = pin. next (); ch = str. charAt (0); System. out. println (); while (ch! = 'Y' & ch! = 'Y' & ch! = 'N' & ch! = 'N') {System. out. print ("incorrect input, please enter again:"); str = pin. next (); ch = str. charAt (0);} if (ch = 'n' | ch = 'n') {break ;}} System. out. println (); System. out. println ("the system returns to the main menu! "); This. menu ();} public static void main (String [] args) throws IOException {Student stu = new Student (); for (int I = 0; I <2; I ++) {s [I] = new Student ();} stu. menu ();}}

The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.