* * @copyright by lzyrapx on 2016/4/12.
* @name: Java student Performance management system.
*@ function: Students related information, input, query, statistics, modification, etc.. * @PS: The graphical interface of the student management system does not require to do.
* * Import Java.util.Scanner;
Import java.lang.*;
Import java.io.*;
Class Student {private static student[] s=new student[100];//input student upper limit int n=0;
private String name;
private int num;
Private String classage;
private int Chinese;
private int math;
private int 中文版;
Determine if there is input student information public void judge () throws IOException {int i;
Char ch;
String str;
Scanner in=new Scanner (system.in);
if (n==0) {System.out.println ("You have not entered any student information, whether input (y/n):");
Str=in.next ();
Ch=str.charat (0);
while (ch!= ' y ' &&ch!= ' y ' &&ch!= ' n ' &&ch!= ' n ') {System.out.println ("entered incorrectly, reenter:");
Str=in.next ();
Ch=str.charat (0); if (ch== ' Y ') | |
ch== ' y ') {this.add (); } if (ch== ' N ' | |
ch== ' n ') {this.menu (); }}//Menu public void menu () throws IOException//throws an exception, calls this method to handle the exception, and if the main method throws an exception, it is handled by the Java virtual machine.Same.
{int A;
Scanner in=new Scanner (system.in);
System.out.println ("************* Student Information Management System *************");
SYSTEM.OUT.PRINTLN ("* * * 1. Input student Information");
SYSTEM.OUT.PRINTLN ("* * * 2 show student Information");
SYSTEM.OUT.PRINTLN ("* * * 3. Revise student information");
SYSTEM.OUT.PRINTLN ("* * * 4. Delete student Information");
SYSTEM.OUT.PRINTLN ("* * * 5. View student Information");
SYSTEM.OUT.PRINTLN ("* * * 0. Exit management system");
System.out.println ("******************************************");
System.out.print ("Please select (0~5):");
A=in.nextint (); while (a<0| |
a>5) {System.out.print ("input is not valid, please re-enter:");
A=in.nextint ();
Switch (a) {case 1:this.add ();
Case 2:this.show ();
Case 3:this.modif ();
Case 4:this.delete ();
Case 5:this.look (); Case 0:system.out.println ("successfully exited the system ...") ");
System.exit (0);
}//input student Information public void Add () throws IOException { String str,str1,str2;
int i,num1,t=1;
Char ch,ch1; FileWriter fw=new FileWriter ("E://student.txt", true);
The student information input into the designated TXT file fw.write ("Input of Student Information List \r\n\r\n School Number name Class language score of the grade of English grades \ r \ n");
Scanner in=new Scanner (system.in);
while (t==1) {System.out.println ("Please enter student number:");
Num1=in.nextint ();
Determines whether the number is repeated for (i=0;i<n;i++) {while (S[I].NUM==NUM1) {System.out.println ("This number already exists, please re-enter");
System.out.print ("Please enter the school number:");
Num1=in.nextint ();
}} s[n].num=num1;
Str2=string.valueof (NUM1);
Fw.write (str2+ "");
System.out.println ();
System.out.println ("Please enter student name:");
S[n].name=in.next ();
Fw.write (s[n].name+ "");
System.out.println ();
System.out.println ("Please enter Student class:");
S[n].classage=in.next ();
Fw.write (s[n].classage+ "");
SYSTEM.OUT.PRINTLN ("Please input the student's language score:");
S[n].chinese=in.nextint ();
Fw.write (s[n].chinese+ "");
SYSTEM.OUT.PRINTLN ("Please input the student's maths score:"); S[n].Math=in.nextint ();
Fw.write (s[n].chinese+ "");
SYSTEM.OUT.PRINTLN ("Please input student's English score:");
S[n].english=in.nextint ();
Fw.write (s[n].english+ "\ r \ n");
++n;
Fw.close ();
System.out.println ();
System.out.println ("Continue to add (y/n)");
Str=in.next ();
Ch=str.charat (0);
while (ch!= ' n ' &&ch!= ' n ' &&ch!= ' y ' &&ch!= ' y ') {System.out.println ("input is not valid, please re-enter:");
Str=in.next ();
Ch=str.charat (0); } if (ch== ' N ' | |
ch== ' n ') {break;
} System.out.println ();
System.out.print ("Return to System main Menu (y/n)");
Str1=in.next ();
Ch1=str1.charat (0);
while (ch1!= ' y ' &&ch1!= ' y ' &&ch1!= ' n ' &&ch1!= ' n ') {System.out.println ("Input is invalid, please re-enter:");
Str1=in.next ();
Ch1=str1.charat (0); if (ch1== ' Y ') | |
ch1== ' y ') {this.menu (); } if (ch1== ' N ' | |
ch1== ' n ') {System.out.println (""); SYSTEM.OUT.PRINTLN ("You have withdrawn from the system ...)
");
System.exit (0);
}//Display student Information public void Show () throws IOException {int i;
This.judge (); SystEm.out.println ("The operation of a total of" +n+ "Students!");
System.out.println ("The Student information you entered is as follows:");
System.out.println ();
System.out.println ("School number \ t name \ t class \ t language \ t math t English"); for (i=0;i<n;i++) {System.out.println (s[i].num+ "+s[i].name+" "+s[i].classage+"
"+s[i].chinese+" "+s[i].math+" "+s[i].english";
SYSTEM.OUT.PRINTLN ("System return main Menu!");
This.menu ();
///delete student information public void Delete () throws IOException {This.judge ();
int j=0,t=0,k=0,num1;
Char ch;
String str;
Scanner pin=new Scanner (system.in);
System.out.println ("Please enter the school number to be deleted:");
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 school number you are about 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 that the administrator wants to delete System.out.println ("number \ t name \ t class");/This feature is temporarily unprepared for extensibility
System.out.println (s[t].num+ "" +s[t].name+ "" +s[t].classage); System.oUt.println ();
System.out.println ("You are sure to delete (y/n):");
Str=pin.next ();
Ch=str.charat (0);
while (ch!= ' y ' &&ch!= ' y ' &&ch!= ' n ' &&ch!= ' n ') {System.out.println ("Input is invalid, please re-enter:");
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 ("Student data deleted successfully!");
SYSTEM.OUT.PRINTLN ("System return main Menu!");
This.menu (); ()}//view student Information public void look () throws IOException {FileReader fr=new filereader ("E://student.txt");
View student information in txt int A;
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 ();
///Modify student Information 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; Scanner PiN=new Scanner (system.in);
System.out.println ("Please enter the school number 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 school number you want to change does not exist.
"); SYSTEM.OUT.PRINTLN ("The system will return to the main menu.)
");
This.menu ();
} if (k==1) {//print the student information to be deleted System.out.println ("The Student information you want to revise is as follows:");
SYSTEM.OUT.PRINTLN ("Student number \ t name \ t class");
System.out.println (s[t].num+ "" +s[t].name+ "" +s[t].classage);
System.out.println ("Chinese \ t math \ t English");
System.out.println (s[t].chinese+ "" +s[t].math+ "" +s[t].english);
System.out.println ();
System.out.println ("You are sure to modify (y/n):");
Str=pin.next ();
Ch=str.charat (0);
while (ch!= ' y ' &&ch!= ' y ' &&ch!= ' n ' &&ch!= ' n ') {System.out.println ("Input is invalid, please re-enter:");
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 Revision of the school number * * * * *);
SYSTEM.OUT.PRINTLN ("* * * 2. Revise class * * * *)";
SYSTEM.OUT.PRINTLN ("* * * 3. Change name * * * *)";
System.out.println ("****************************************");
SYSTEM.OUT.PRINTLN ("Please choose:");
Moi=pin.nextint ();
Switch (moi) {case 1:system.out.print ("Please enter a new school number:"); Num3=pin.nextint (); s[t].num=num3;break;
Case 2:system.out.print ("Please enter a new class:"); Str1=pin.next (); s[t].classage=str1;break;
Case 3:system.out.print ("Please enter a new name:"); Str2=pin.next (); s[t].name=str2;break; SYSTEM.OUT.PRINTLN ("The data has been modified successfully.)
");
} System.out.print ("Continue to modify (y/n)");
Str=pin.next ();
Ch=str.charat (0);
System.out.println ();
while (ch!= ' y ' &&ch!= ' y ' &&ch!= ' n ' &&ch!= ' n ') {System.out.print ("Input is invalid, please re-enter:");
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<100;i++) {s[i]=new Student ();
} stu.menu ();
}
}
Partial Effect Chart:
If reproduced, please indicate the source. Thank you.