Java Write Student management system

Source: Internet
Author: User

Package Homework08;
/* Debug a morning, Harvest: learned the use of yesterday's debug
Lessons learned: Student stus[]=new student[2];
for (int i=0;i<stus.length;i++) {
Stus[i]=new Student (); it should be written out of the loop, otherwise it will be initialized every time.
}*/

Import Java.util.Scanner;

public class Main {
public static void Main (String[]args) {

/**
* 1: Create a simple student information management system, through the keyboard selection operation to add students (student number, name, gender, age, score) information,
* This information is stored through an array,
* 2: Can be queried for one or all student information
* 3: Modify student information
* 4: Delete the student information operation. (Some optimizations are required, for example, if the user is entering information to meet the required processing).
*/
Student Stus[]=new student[2];
for (int i=0;i<stus.length;i++) {
Stus[i]=new Student ();
}

while (true) {
SYSTEM.OUT.PRINTLN ("--------------------Welcome to the student management System--------------------------");
System.out.println ("1: Input student Information");
System.out.println ("2: Modify student Information");
System.out.println ("3: Delete student information");
System.out.println ("4: Inquiry of Student Information");
System.out.println ("0: Exit system");
System.out.println ("-----------Please enter option----------------");


Scanner scanner=new Scanner (system.in);
int M=scanner.nextint ();


int js;

Switch (m) {
Enter student information
Case 1:

{//Enter student's name
int z=0;
System.out.println ("Please enter student information");
System.out.println ("Please enter student's name:");
String Name=scanner.next ();
Stus[z].setname (name);
Enter Student's study number
System.out.println ("Please enter student number:");
String Stunum=scanner.next ();
Stus[z].setstunum (Stunum);
Enter student gender
System.out.println ("Please enter Student Gender:");
String Gender=scanner.next ();
Stus[z].setgender (gender);
Enter student age
System.out.println ("Please enter Student Age:");
int Age=scanner.nextint ();
Stus[z].setage (age);

Enter student Scores
SYSTEM.OUT.PRINTLN ("Please input student results:");
float score=scanner.nextfloat ();
Stus[z].setscore (score);
SYSTEM.OUT.PRINTLN ("-----------------input End------------------");

z++;}
Break

Case 2:{
Boolean beep=false;//beep Determine if student information is found
System.out.println ("Please enter the student number you want to change:");
String Stunum4=scanner.next ();
for (int i=0;i<stus.length;i++) {
if (Stunum4.equals (Stus[i].getstunum ())) {
Re-enter student's name
System.out.println ("Please enter your student name");
String Name1=scanner.next ();
Stus[i].setname (NAME1);
Re-enter student's study number
System.out.println ("Please enter student number");
String Stunum1=scanner.next ();
Stus[i].setstunum (STUNUM1);
Re-enter the student's gender
System.out.println ("Please enter student gender");
String Gender1=scanner.next ();
Stus[i].setgender (Gender1);
Re-enter the student's age
System.out.println ("Please enter student age");
int Age1=scanner.nextint ();
Stus[i].setage (AGE1);
Re-enter students ' grades
System.out.println ("Please enter student results");
Float score1=scanner.nextfloat ();
Stus[i].setscore (Score1);
SYSTEM.OUT.PRINTLN ("----------modification completed--------------");
Beep=true;

}
}
if (beep) {
SYSTEM.OUT.PRINTLN ("No information is found for students, please redefine");
}

}
Break
Case 3:{
Boolean Bo=false;//bo determines whether the student information is found
int w=0;
System.out.println ("Please enter the student number you want to delete:");
String Stunum2=scanner.next ();
for (int i=0;i<stus.length;i++)
{if (Stus[i].getstunum (). Equals (stuNum2)) {
System.out.println ("Find to student, please indicate whether to delete.") Please enter Yes or no: ");
String Sf=scanner.next ();
if (sf== "yes") {
/**
* Put the last student information in the previous array element
*/
for (int j=i;j<stus.length-w;j++) {
STUS[J]=STUS[J+1];
}
for (int k=999;k>stus.length-w;k--) {
Stus[k]=null;
}
Bo=true;
}

else if (sf== "no") {
Break
}

}

if (bo) {
SYSTEM.OUT.PRINTLN ("The data you entered is wrong, please re-enter");
Break
}
}
}
Break
Query Student Information
Case 4:{
Boolean boo=false;
System.out.println ("Please enter the student number of your enquiry");
String Stunum3=scanner.next ();
for (int i=0;i<stus.length;i++) {
if (Stunum3.equals (Stus[i].getstunum ())) {
System.out.println ("The Student's name:" + stus[i].getname ());
System.out.println ("The Student's study number:" +stus[i].getstunum ());
System.out.println ("The Student's Gender:" +stus[i].getgender ());
System.out.println ("The Student's Age:" +stus[i].getage ());
System.out.println ("The Student's score:" +stus[i].getscore ());
}

}
}
Break
Exit system
Case 0:{
System.out.println ("--------exit system---------------");
Scanner.close ();//scanner.close () indicates input is off
System.exit (0);//system.exit (0) indicates system shutdown

}

}



}


}
}

Package Homework08;
Create a student student class that contains properties and features.
public class Student {
Attributes (school number, name, gender, age, score)
String Stunum;
String name;
String gender;
int age;
Float score;

functions as follows
Enter study number
public void Setstunum (String stunum) {
This.stunum=stunum;
}
Output number
Public String Getstunum () {
return stunum;
}

Enter a name
public void SetName (String name) {
This.name=name;
}
Output name
Public String GetName () {
return name;
}

Enter gender
public void Setgender (String gender) {
This.gender=gender;
}
Output gender
Public String Getgender () {
return gender;
}
Enter age
public void Setage (int.) {
This.age=age;
}
Output age
public int getage () {
return age;
}
Enter score
public void SetScore (float score) {
This.score=score;
}
Output score
public float Getscore () {
return score;
}

}

Java Write Student management system

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.