《学生成绩管理系统(java语言).doc》由会员分享,可在线阅读,更多相关《学生成绩管理系统(java语言).doc(17页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、Four short words sum up what has lifted most successful individuals above the crowd: a little bit more.-author-date学生成绩管理系统(java语言)学生成绩管理系统学生成绩管理系统import java.util.*;import java.io.*;class Student implements Serializable String name;long no;private String course=os,java,math;double cscore=0,0,0; pub
2、lic Student(String name,long no,double a,double b,double c)this.name=name;this.no=no;this.cscore0=a;this.cscore1=b;this.cscore2=c;Override public String toString()return this.name+ +this.no+ +this.course0+:+this.cscore0+ +this.course1+:+this.cscore1+ +this.course2+:+this.cscore2;public class Objectp
3、rivate static Scanner scanner=new Scanner(System.in);public Student read()throws ExceptionObjectInputStream objIn=new ObjectInputStream(new FileInputStream(stus.data);int num=objIn.readInt();Student stus=new Studentnum;for(int i=0;inum;i+)stusi=(Student)objIn.readObject();objIn.close();return stus;p
4、ublic void add(Student stus)throws ExceptionStudent s=new Studentstus.length+1;for(int i=0;is.length-1;i+)si=stusi;System.out.print(请输入要添加的学生信息:n+姓名:);String name=scanner.next();System.out.print(学号:);long no=scanner.nextInt();System.out.print(os成绩:);double cscore0=scanner.nextDouble();System.out.pri
5、nt(java成绩:);double cscore1=scanner.nextDouble();System.out.print(math成绩:);double cscore2=scanner.nextDouble();ss.length-1=new Student(name,no,cscore0,cscore1,cscore2);save(s);System.out.println(添加成功!);public void dispAll(Student stus)System.out.println(现有Student信息为:);for(Student stu:stus)System.out.
6、println(stu);public void save(Student stus)throws ExceptionObjectOutputStream objOut=new ObjectOutputStream(new FileOutputStream(stus.data);objOut.writeInt(stus.length);for(Student stu:stus)objOut.writeObject(stu);objOut.close();public void findById(Student stus)int no=0,i=0;System.out.print(请输入学号:)
7、;no=scanner.nextInt();for(i=0;istus.length;i+)if(stusi.no=no)System.out.println(stusi);break;if(stusi.no!=no&i=stus.length-1)System.out.println(无该生信息!);public void findByName(Student stus)String name=;System.out.print(请输入姓名:);name=scanner.next();for(int i=0;istus.length;i+)if(name.equalsIgnoreCase(s
8、tusi.name)=true)System.out.println(stusi);break;if(name.equalsIgnoreCase(stusi.name)=false&i=stus.length-1)System.out.println(无该生信息!);public void delById(Student stus)throws Exceptionint no=0,i=0;System.out.print(请输入学号:);no=scanner.nextInt();for(i=0;istus.length;i+)if(stusi.no=no)System.out.println(
9、stusi);stusi=null;save(stus);System.out.println(删除成功!);break;if(stusi.no!=no&i=stus.length-1)System.out.println(无该生信息!);public static void main(String args)throws ExceptionObject demo=new Object();Student stus=new Student(zhang,1,90,90,98),new Student(wang,2,80,80,89),new Student(li,3,70,70,79);Syst
10、em.out.print(请输入操作的编号:);System.out.print(n);int choice=0;doSystem.out.println(1 添加 2 显示所有学生信息 3 按学号查找 4 按姓名查找 5 按学号删除 6 保存 0 退出);choice=scanner.nextInt();switch(choice)case 1: demo.add(demo.read();break;case 2: demo.dispAll(demo.read();break;case 3: demo.findById(demo.read();break;case 4: demo.findByName(demo.read();break;case 5: demo.delById(demo.read();break;case 6: demo.save(stus);break;case 0: break; default: System.out.println(Error!);while(choice!=0);-