System.out.println ("function menu is as follows:");
System.out.println ("1. Input student Information");
System.out.println ("2. Inquiry student information According to school number");
System.out.println ("3. Modify student Information");
System.out.println ("4. Delete Student information according to school number");
System.out.println ("5. Statistical student Average test results");
System.out.println ("6. Exit system");
System.out.println ("-------------------");
SYSTEM.OUT.PRINTLN ("Please choose:");
String Index=input.next ();
if ("1". Equals (index)) {
Input Student Information
Save ();
}else if ("2". Equals (index)) {
Check student information according to school number
Search ();
}else if ("3". Equals (index)) {
Modify Student Information
Modify ();
}else if ("4". Equals (index)) {
Delete Student information according to school number
Remove ();
}else if ("5". Equals (index)) {
Average test scores of statistical trainees
Average ();
}else if ("6". Equals (index)) {
Exit system
System.exit (0);
}else{
SYSTEM.OUT.PRINTLN ("Input error, please re-enter.") ");
}
Start ();
}
/**
* Average scores of students in statistical examinations
*/
private void average () {
int sum=0;
for (int i=0;i<list.size (); i++) {
Student S=list.get (i);
Sum+=s.getscore ();
}
float ave=sum/list.size ();
System.out.println ("The average student score is:" +ave);
}
/**
* Delete Student information according to school number
*/
private void Remove () {
System.out.println ("Enter the student number to be deleted:");
String Num=input.next ();
for (int i = 0; i < list.size (); i++) {
Student S=list.get (i);
if (S.getstudentnum (). Equals (num)) {
List.remove (s);
System.out.println ("delete succeeded.") ");
}
}
}
/**
* Revise student information
*/
private void Modify () {
System.out.println ("Enter the student number to be modified:");
String Num=input.next ();
for (int i = 0; i < list.size (); i++) {
Student S=list.get (i);
if (S.getstudentnum (). Equals (num)) {
System.out.println ("Enter new student Name:");
String Name=input.next ();
System.out.println ("Enter new student Age:");
int Age=input.nextint ();
System.out.println ("Enter new student score:");
int Score=input.nextint ();
/**
* Inquiry student Information according to the school number
*/
private void Search () {
System.out.println ("Please enter the school number:");
String Num=input.next ();
Student S=null;
for (Student stu:list) {
if (Stu.getstudentnum (). Equals (num)) {
S=stu;
Break
}
}
if (s!=null) {
System.out.println ("School Number:" +s.getstudentnum ());
System.out.println ("Name:" +s.getname ());
System.out.println ("Age:" +s.getage ());
System.out.println ("Score:" +s.getscore ());
}else{
System.out.println ("The school number does not exist.") ");
}
/*
Student S=null;
for (int i=0;i<list.size (); i++) {
S=list.get (i);
if (S.getstudentnum (). Equals (num)) {
StringBuffer sb=new StringBuffer ();
Sb.append (S.getstudentnum ()). Append ("\t\t"). Append (S.getname ()). Append ("\t\t"). Append (S.getage ()). Append ("\ t \ t "). Append (S.getscore ());
Sb.append (S.getstudentnum () + "\t\t" +s.getname () + "\t\t" +s.getage () + "\t\t" +s.getscore ());
String str=sb.tostring ();
System.out.println (str);
}else {
System.out.println ("The school number does not exist.") ");
}
}*/
}
/**
* Input Student Information
*/
private void Save () {
System.out.println ("Please enter the school number:");
String Num=input.next ();
System.out.println ("Please enter Name:");
String Name=input.next ();
System.out.println ("Please enter Age:");
int Age=input.nextint ();
System.out.println ("Please enter the score:");
int Score=input.nextint ();
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.