Java Student Information Management system and support user name login

Source: Internet
Author: User

Tag:while    judgment    get    username    blog    stat    Enter password     no    data   

Package Zzzzzzzz;import java.io.*;p ublic class Text {public static void main (string[] args) throws MyException, Ioexceptio n {Login l=new login (); L.login ();}} Class Student{private string Stunumber;private string name;private string age;private string Sex;private string score;pub LIC void Set_stunumber (String stu) {stunumber=stu;} Public String Get_stunumber () {return stunumber;} void Set_name (String na) {name=na;} String get_name () {return name;} void Set_age (String agee) {Age=agee;} String Get_age () {return age;} void Set_sex (String sexx) {Sex=sexx;} String Get_sex () {return sex;} void Set_score (String scoree) {score=scoree;} String Get_score () {return score;}} Class Studentmanager{int n=0; Student ss[]=new student[50];//traverse student information void Showstudent () {for (int i=0;i<=n;i++) {System.out.println ("Study No.:" +ss[i]. Get_stunumber () + "Name:" +ss[i].get_name () + "Age:" +ss[i].get_age () + "Gender:" +ss[i].get_sex () + "score:" +ss[i].get_score () + "\ t \ n ");}}            Determines whether the number already exists in Boolean Panduan (String St) {Boolean flag=true; for (int i=0;i<n;i++) {if (Ss[i].get_stunumber (). Equals (ST)) flag= false;        else flag= true;    } return flag; }//Add student information void addstudent (String stunumber,string name,string age,string b,string score) {ss[n]=new Student (); Ss[n] . Set_stunumber (Stunumber); Ss[n].set_name (name); Ss[n].set_age (age); Ss[n].set_sex (b); Ss[n].set_score (score); n++;} Delete Student information void deletestudent (String stunumber) throws myexception{for (int i=0;i<=n;i++) {if (Ss[i].get_stunumber (). Equals (Stunumber)) {System.out.println ("Student Number:" +stunumber+ "students have been deleted!) "), if (n==1) {System.out.println (" array is empty "); ss[0]=new Student ();} else {for (int j=i;j<=n;j++) {ss[j]=ss[j+1];} n--;}} Else{throw New MyException ("The student does not exist!") ");}}} Modify student information void Updatestudent (String stu1,string name,string age,string sex,string score) throws myexception{for (int i=0;i <=n;i++) {if (Ss[i].get_stunumber (). Equals (STU1)) {ss[i]=new Student (); Ss[i].set_stunumber (STU1); ss[i].set_name (name); Ss[i].set_age (age); SS[I].set_sex (Sex); Ss[i].set_score (score);} else throw new MyException ("The student was not found!") ");}} Query Student information void Selectstudent (String number) throws myexception{for (int i=0;i<=n;i++) {if (Ss[i].get_stunumber (). Equals (number)) {System.out.println ("No.:" +ss[i].get_stunumber () + "Name:" +ss[i].get_name () + "Age:" +ss[i].get_age () + " Gender: "+ss[i].get_sex () +" score: "+ss[i].get_score () +" \t\n ");} else throw new MyException ("The student was not found!") ");}} Number of failed statistics void Tongji () {int s=0;for (int i=0;i<=n;i++) {int a=integer.parseint (Ss[i].get_score ())); if (a<=60) {s= s+1; System.out.println ("School Number:" +ss[i].get_stunumber () + "Name:" +ss[i].get_name () + "Age:" +ss[i].get_age () + "Gender:" +ss[i].get_ Sex () + "score:" +ss[i].get_score () + "\t\n");}} System.out.println ("The number of failed persons is:" +s+ "person");} Input interface void Showface () {System.out.println ("*****************************"); System.out.println ("Shijiazhuang Railway University student Information Management System"); System.out.println ("*****************************"); System.out.println ("1. Traverse the output of student information"); System.out.println ("2. New Student Information Entry"); System.out.println ("3. Delete Student Information"); System.out.println ("4. Modify student Information"); System.oUt.println ("5. Query student Information"); System.out.println ("6. Student information Statistics"); System.out.println ("7 exit.");} Class Login{user Users=new User ("001", "123456");//username, password//login void Login () throws MyException, ioexception{ BufferedReader in=new BufferedReader (New InputStreamReader (system.in));D Ataoutputstream out=new DataOutputStream ( New Bufferedoutputstream (New FileOutputStream ("Student.txt", True)), for (int i=1;i<=3;i++) {System.out.println (" Please enter User id: "); String Id=in.readline (); System.out.println ("Please enter password:"); String Pass=in.readline (), if ((Users.uername.equals (ID)) && (Users.passage.equals (pass))) {Studentmanager SM =new Studentmanager (); while (true) {sm.showface (); SYSTEM.OUT.PRINTLN ("Please select:"); String Choose=in.readline (), if (Choose.startswith ("1")) {sm.showstudent ();} else if (Choose.startswith ("2")) {System.out.print ("Please enter the study number:"); String Stu=in.readline (); System.out.print ("Please enter Name:"); String Name=in.readline (); System.out.print ("Please enter Age:"); String Age=in.readline (); System.out.println ("Please enter gender (true male, false female):"); String Sex=in.readline (); SysteM.out.print ("Please enter the score:"); String Score=in.readline (); if (Sm.panduan (stu)) {sm.addstudent (Stu, name, age, sex, score); SYSTEM.OUT.PRINTLN ("created successfully! Out.writeutf ("| School number:" +stu+ "| Name:" +name+ "| Age:" +age+ "| Gender:" +sex+ "| Score:" +score+ "|\t\t\n\n");} Elsethrow New MyException ("The student already exists, do not add it repeatedly");} else if (Choose.startswith ("3")) {System.out.println ("Please enter the study number:"); String Stu=in.readline (); if (! ( Sm.panduan (Stu)) {sm.deletestudent (stu);} else throw new MyException ("The school number does not exist!") ");} else if (Choose.startswith ("4")) {System.out.println ("Please enter the study number:"); String Stu=in.readline (); System.out.println ("Please enter Name:"); String Name=in.readline (); System.out.println ("Please enter Age:"); String Age=in.readline (); System.out.print ("Please enter gender (true male, false female):"); String Sex=in.readline (); System.out.print ("Please enter the score:"); String Score=in.readline (); if (! ( Sm.panduan (Stu)) {sm.updatestudent (Stu, name, age, sex, score); Out.writeutf ("| Study No.:" +stu+ "| Name:" +name+ "| Age:" +age+ "| Gender: "+sex+" | Score: "+score+" |\t\n ");} else throw new MyException ("The school number does not exist!") ");} else if (Choose.startswith ("5")) {System.out.println ("Please enter the study number:"); String Stu=in.readline (); if (! ( Sm.panduan (Stu)) {sm.selectstudent (stu);} else throw new MyException ("The school number does not exist!") ");} else if (Choose.startswith ("6")) {Sm.tongji ();} else if (Choose.startswith ("7")) {in.close (); Out.close ();   System.exit (0); }else {throw new MyException ("Select Error, please re-select");}}}   ELSESYSTEM.OUT.PRINTLN ("User ID or password is wrong, please re-enter");} throw new MyException ("The card is locked! ");}} Class User{string Uername; String Passage; User (String user,string pass) {this.uername=user;this.passage=pass;} void Set_uername (String use) {uername=use;} String Get_uername () {return uername;} void Set_passage (String pass) {passage=pass;} String Get_passage () {return passage;}} Class MyException extends Exception{public myexception (String e) {super (E);}}

  

Java Student Information Management system and support user name login

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.