Java implements the student management system and java student management system

Source: Internet
Author: User

Java implements the student management system and java student management system

Project Description: You can use an administrator account to log on and manage student information. You can add, modify, delete, and query student information.

Knowledge Point: array, do {} while LOOP, for loop, if statement, switch Condition Statement

Flowchart of the student management system

Import java. util. extends; public class Stu {public static void main (String [] args) {Using SC = new using (System. in); boolean flag = false; int stuNum = 0; String [] stuName = new String [20]; String [] stuId = new String [20]; System. out. println ("**********************************"); system. out. println ("**"); System. out. println ("**"); System. out. println ("* Welcome to Derun Science and Technology Educational Administration System *"); System. out. println (" ** "); System. out. println ("**"); System. out. println ("**********************************"); system. out. println ("\ n"); do {System. out. println ("************************"); System. out. println ("Enter the operation you want to perform"); System. out. println ("1. log on to the system. exit System "); String num1 = SC. next (); if (num1.equals ("1") {flag = false; break;} if (num1.equals ("2") {System. exit (0); flag = false;} else {System. out. println ("incorrect input. Please try again "); Flag = true ;}while (flag); do {System. out. println ("Enter Logon account"); String username = SC. next (); System. out. println ("Enter password"); String password = SC. next (); if (username. equals ("tiantian") & password. equals ("dahai") {System. out. println ("welcome" + username); flag = false;} else {System. out. println ("incorrect account or password, please log on again"); flag = true ;}}while (flag); do {System. out. println ("*********************"); System. out. printl N ("Enter the operation you want"); System. out. println ("************************************* ***************************************" ); system. out. println ("1. add Student Information 2. delete Student Information 3. modify Student name 4. view Student Information 5. exit System "); System. out. println ("************************************* ***************************************" ); string num2 = SC. next (); switch (num2) {case "1": System. out. println ("enter the name of the student to be added"); stuName [stuNum] = SC. next (); Syst Em. out. println ("Enter the student ID to be added"); stuId [stuNum] = SC. next (); stuNum ++; System. out. println ("successfully added"); flag = true; break; case "2": System. out. println ("Enter the student ID you want to delete"); String stuIdDel = SC. next (); for (int I = 0; I <stuName. length; I ++) {if (stuIdDel. equals (stuId [I]) {stuId [I] = null; stuName [I] = null;} else {System. out. println ("no student ID for this student") ;}} flag = true; break; case "3": System. out. println ("Enter the student ID you want to modify "); String stuIdUp = SC. next (); System. out. println ("enter a new student name"); String stuNameUp = SC. next (); for (int I = 0; I <stuId. length; I ++) {if (stuIdUp. equals (stuId [I]) {stuName [I] = stuNameUp;} else {System. out. println ("no student ID for this student") ;}} flag = true; break; case "4": for (int I = 0; I <stuName. length; I ++) {if (stuName [I] = null) {continue;} System. out. println ("the Student name is" + stuName [I] + "\ t the student's student ID is" + stuId [I]);} flag = true; Break; case "5": System. exit (0); default: System. out. println ("incorrect input. Please try again !!! "); Flag = true; }}while (flag );}}

The following code is optimized:

Import java. util. extends; public class Stu {public static void main (String [] args) {Using SC = new using (System. in); boolean flag = false; boolean ss = true; boolean aa = true; boolean bb = true; boolean cc = true; int stuNum = 0; string [] stuName = new String [20]; String [] stuId = new String [20]; String [] userNames = new String [5]; string [] passWords = new String [5]; System. out. println ("****** **************************************** *********"); System. out. println ("**"); System. out. println ("**"); System. out. println ("* Welcome to Derun Science and Technology Educational Administration System *"); System. out. println ("**"); System. out. println ("**"); System. out. println ("************************************* ******************"); system. out. println ("\ n"); do {System. out. println ("************************"); if (userNames [0] = null) {System. out. print Ln ("Enter the operation you want to perform (you have not logged on to the account first)");} else {System. out. println ("Enter the operation you want to perform (You have registered as an administrator and can log on to the System)");} System. out. println ("1. register an account 2. log on to the system. forgot password 4. exit System "); String num1 = SC. next (); switch (num1) {case "1": do {System. out. println ("Enter the user name you want to register"); userNames [stuNum] = SC. next (); System. out. println ("enter the password you want to register"); String password1 = SC. next (); System. out. println ("enter the password again"); String password2 = SC. next (); if (password1. Equals (password2) {passWords [stuNum] = password1; System. out. println ("Congratulations! Account: "+ userNames [stuNum] +" created successfully "); flag = true;} else {System. out. println ("the two passwords are inconsistent, Please create again"); flag = false ;}} while (! Flag); stuNum ++; continue; case "2": flag = false; break; case "3": System. out. println ("Enter the account to query the password"); String username1 = SC. next (); for (int I = 0; I <userNames. length; I ++) {if (username1.equals (userNames [I]) {System. out. println (the password for "Account" + username1 + "is" + passWords [I]); aa = false;} flag = true;} if (aa = true) {System. out. println ("this account information is not available"); aa = true; flag = true;} continue; case "4": System. exit (0); fl Ag = false; default: System. out. println ("incorrect input, please enter again"); flag = true ;}} while (flag); do {System. out. println ("Enter Logon account"); String username = SC. next (); System. out. println ("Enter password"); String password = SC. next (); for (int I = 0; I <userNames. length; I ++) {if (username. equals (userNames [I]) & password. equals (passWords [I]) {System. out. println ("welcome" + username); ss = false; break ;}} if (ss = true) {System. out. println (" Incorrect account or password. Please log on again "); ss = true ;}} while (ss); do {System. out. println ("*********************"); System. out. println ("Enter the operation you want"); System. out. println ("************************************* ***************************************" ); system. out. println ("1. add Student Information 2. delete Student Information 3. modify Student name 4. view Student Information 5. exit System "); System. out. println ("************************************* ***************************************" ); string nu M2 = SC. next (); switch (num2) {case "1": System. out. println ("enter the name of the student to be added"); stuName [stuNum] = SC. next (); System. out. println ("Enter the student ID to be added"); stuId [stuNum] = SC. next (); stuNum ++; System. out. println ("successfully added"); flag = true; break; case "2": System. out. println ("Enter the student ID you want to delete"); String stuIdDel = SC. next (); for (int I = 0; I <stuName. length; I ++) {if (stuIdDel. equals (stuId [I]) {stuId [I] = stuId [stuId. length-1]; StuName [I] = stuName [stuName. length-1]; System. out. println ("deleted successfully! "); Flag = true; cc = false ;}} if (cc = true) {System. out. println ("no student ID for this student"); flag = true;} break; case "3": System. out. println ("Enter the student ID you want to modify"); String stuIdUp = SC. next (); for (int I = 0; I <stuId. length; I ++) {if (stuIdUp. equals (stuId [I]) {System. out. println ("enter a new student name"); String stuNameUp = SC. next (); stuName [I] = stuNameUp; System. out. println ("modified successfully! "); Flag = true; bb = false ;}} if (bb = true) {System. out. println ("no student ID for this student"); flag = true;} break; case "4": for (int I = 0; I <stuName. length; I ++) {if (stuName [I] = null) {continue;} System. out. println ("the Student name is" + stuName [I] + "\ t the student's student ID is" + stuId [I]);} flag = true; break; case "5": System. exit (0); default: System. out. println ("incorrect input. Please try again !!! "); Flag = true; }}while (flag );}}

This code is written by Java beginners. The method is not very suitable for entertainment only.

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.