/*
*@------環創移動端課後作業------
*@copyright by lzy on 2016/4/12.
*@name:java學生成績管理系統.
*@功能:學生相關信息,錄入,查詢,統計,修改等....
*@PS:圖形界面的學生管理系統不要求就不做了.
*/
import java.util.Scanner;
import java.lang.*;
import java.io.*;
class Student
{
private static Student[] s=new Student[100]; //錄入學生上限
int n=0;
private String name;
private int num;
private String classAge;
private int chinese;
private int math;
private int english;
//判斷是否有錄入學生信息
public void judge() throws IOException
{
int i;
char ch;
String str;
Scanner In=new Scanner(System.in);
if(n==0)
{
System.out.println("你還沒有錄入任何學生信息,是否錄入(Y/N):");
str=In.next();
ch=str.charAt(0);
while(ch!='Y'&&ch!='y'&&ch!='N'&&ch!='n')
{
System.out.println("輸入有誤,請重新輸入:");
str=In.next();
ch=str.charAt(0);
}
if(ch=='Y'||ch=='y')
{
this.add();
}
if(ch=='N'||ch=='n')
{
this.menu();
}
}
}
//菜單
public void menu() throws IOException //將異常拋出,調用這個方法去處理異常,如果main方法也將異常拋出,則交給Java虛擬機來處理,下同.
{
int a;
Scanner in=new Scanner(System.in);
System.out.println("*************學生信息管理系統*************");
System.out.println("***** 1.錄入學生信息 ******");
System.out.println("***** 2.顯示學生信息 ******");
System.out.println("***** 3.修改學生信息 ******");
System.out.println("***** 4.刪除學生信息 ******");
System.out.println("***** 5.查看學生信息 ******");
System.out.println("***** 0.退出管理系統 ******");
System.out.println("******************************************");
System.out.print("請選擇(0~5):");
a=in.nextInt();
while(a<0||a>5)
{
System.out.print("輸入無效,請重新輸入:");
a=in.nextInt();
}
switch(a)
{
case 1:this.add();break;
case 2:this.show();break;
case 3:this.modif();break;
case 4:this.delete();break;
case 5:this.look();break;
case 0:System.out.println("成功退出系統!!!");System.exit(0);break;
}
}
//錄入學生信息
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); //將學生信息錄入指定的txt文件中
fw.write(" 錄入的學生信息列表\r\n\r\n學號 姓名 班級 語文成績 數學成績 英語成績\r\n");
Scanner In=new Scanner(System.in);
while(t==1)
{
System.out.println("請輸入學生學號:");
num1=In.nextInt();
//判斷學號是否重復
for(i=0;i部分效果圖:




