//student.javapackage com.sran.www;import java.util.Arrays;import java.util.Scanner;public class Student implements Comparable<Student>{int num;String name;int age;double[]s;double sum; //存儲學生的總分public Student(){s=new double[3];}public static boolean insert(){Scanner sc=new Scanner(System.in);String str=null;boolean be=true;do{Student stud=new Student();System.out.//StudentTestpackage com.sran.www;import java.util.Scanner;import java.util.Set;import java.util.TreeSet;public class StudentTest {static Set<Student>set=null; //定義集合,存儲學生信息public void fun(){int i;boolean b,bt;set=new TreeSet<Student>(); do{int flag=0;System.out.println("請輸入1,2,3,4,5 1代表錄入,2代表刪除,3代表查找,4代表顯示學生總成績排名,5代表更新某個學生數據");System.out.print("請輸入:");Scanner sc=new Scanner(System.in);int n=sc.nextInt();switch(n){case 1:{b=Student.insert(); if(b==true){System.out.println("正常結束錄入操作.....");}flag=1;break;}case 2:{b=Student.delete(); if(b==true){System.out.println("正常結束刪除操作.....");}flag=1;break;}case 3:{b=Student.seek();if(b==true){System.out.println("正常結束查詢操作.....");}flag=1;break;}case 4:{System.out.println("開始排名學生信息.....");System.out.println("學生按總成績排名:");for(Student stud:set){System.out.println(stud);System.out.println();}System.out.println("正常結束排名操作.....");flag=1;break;}case 5:{b=Student.update();if(b==true){System.out.println("正常結束更新操作.....");}flag=1;break;}}if(flag==0){System.out.println("你輸入有誤,請重新輸入");}System.out.println();do {bt=false;System.out.println("繼續所有學生信息操作,請輸入1 退出學生信息系統 ,請輸入0");System.out.print("請輸入:");i=sc.nextInt();if(i!=1 && i!=0){bt=true;System.out.println("輸入有誤,請重新輸入");}}while(bt==true);}while(i==1);System.out.println("你已退出學生信息系統.....");}public static void main(String[] args) {new StudentTest().fun();}}
新聞熱點
疑難解答