下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、精选优质文档-倾情为你奉上学生成绩管理系统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; public Student(String name,long no,double a,double b,double c)=name;this.no=no;this.c
2、score0=a;this.cscore1=b;this.cscore2=c;Override public String toString()return +" "+this.no+" "+this.course0+":"+this.cscore0+" "+this.course1+":"+this.cscore1+" "+this.course2+":"+this.cscore2;public class Objectprivate
3、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;i<num;i+)stusi=(Student)objIn.readObject();objIn.close();retu
4、rn stus;public void add(Student stus)throws ExceptionStudent s=new Studentstus.length+1;for(int i=0;i<s.length-1;i+)si=stusi;System.out.print("请输入要添加的学生信息:n"+"姓名:");String name=scanner.next();System.out.print("学号:");long no=scanner.nextInt();System.out.print("os
5、成绩:");double cscore0=scanner.nextDouble();System.out.print("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("添加成功!");pu
6、blic void dispAll(Student stus)System.out.println("现有Student信息为:");for(Student stu:stus)System.out.println(stu);public void save(Student stus)throws ExceptionObjectOutputStream objOut=new ObjectOutputStream(new FileOutputStream("stus.data");objOut.writeInt(stus.length);for(Studen
7、t stu:stus)objOut.writeObject(stu);objOut.close();public void findById(Student stus)int no=0,i=0;System.out.print("请输入学号:");no=scanner.nextInt();for(i=0;i<stus.length;i+)if(stusi.no=no)System.out.println(stusi);break;if(stusi.no!=no&&i=stus.length-1)System.out.println("无该生信
8、息!");public void findByName(Student stus)String name=""System.out.print("请输入姓名:");name=scanner.next();for(int i=0;i<stus.length;i+)if(name.equalsIgnoreCase()=true)System.out.println(stusi);break;if(name.equalsIgnoreCase()=false&&i=stus.length-1
9、)System.out.println("无该生信息!");public void delById(Student stus)throws Exceptionint no=0,i=0;System.out.print("请输入学号:");no=scanner.nextInt();for(i=0;i<stus.length;i+)if(stusi.no=no)System.out.println(stusi);stusi=null;save(stus);System.out.println("删除成功!");break;if(st
10、usi.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);System.out.pr
11、int("请输入操作的编号:");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(
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 书写人生文明的传承:小学主题班会课件
- 小学主题班会课件:珍爱生命爱护环境
- 推广情境面试题及答案
- 感统失调儿童早期干预市场需求缺口分析
- 2025-2030行李车行业数字化转型痛点与工业互联网解决方案
- 金属材料应用行业市场研究及增长潜力报告
- 金属加工行业市场深度分析及发展动态与投资路径研究报告
- 环境监测系统部署与运维手册
- 手抄报比赛:激发创造力小学主题班会课件
- 关于2026年技术难题引进的申请函(7篇范文)
- 第四单元 比例(教学设计)-【大单元教学】六年级数学下册同步备课系列(人教版)
- 2025年中大综评面试题及答案
- 燃气公司员工手册
- 污水处理委托协议
- 2023年珠海横琴粤澳深度合作区执行委员会招聘考试真题
- DL-T5796-2019水电工程边坡安全监测技术规范
- DZ∕T 0201-2020 矿产地质勘查规范 钨、锡、汞、锑(正式版)
- 文艺复兴经典名著选读智慧树知到期末考试答案章节答案2024年北京大学
- 《浙江省城镇既有住宅房屋结构安全排查技术导则(试行)》
- 山东省6项核心制度护理课件
- 医院培训课件:《疑难病例讨论制度及护理查房制度解读》
评论
0/150
提交评论