import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.lang.*;
public class Students extends Applet implements ActionListener
{
Vector StuInf=new Vector();
StudentInf SI;
String xm;
String bj;
int i,j,xh,cj;
static int mid;
Label prompt1=new Label("学生成绩管理系统");
Label prompt2=new Label(" 用户:");
Label prompt3=new Label(" 密码:");
Label prompt4=new Label(" 班级:");
Label prompt5=new Label(" 成绩:");
TextField input1=new TextField(8);
TextField input2=new TextField(8);
TextField input3=new TextField(8);
TextField input4=new TextField(8);
Button btn1=new Button("登录");
Button btn2=new Button("增加");
Button btn3=new Button("修改");
Button btn4=new Button("删除");
public void init()
{
setLayout(new GridLayout(6,3));
add(new Label());
add(prompt1);
add(new Label());
add(prompt2);
add(input1);
add(new Label());
add(prompt3);
add(input2);
add(btn1);
add(prompt4);
add(input3);
add(new Label());
add(prompt5);
add(input4);
add(new Label());
add(btn2);
add(btn3);
add(btn4);
prompt4.setVisible(false);
prompt5.setVisible(false);
input3.setVisible(false);
input4.setVisible(false);
btn2.setVisible(false);
btn3.setVisible(false);
btn4.setVisible(false);
btn1.addActionListener(this);
btn2.addActionListener(this);
btn3.addActionListener(this);
btn4.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
if(e.getActionCommand()=="登录")
{
String a,b;
a=input1.getText();
b=input2.getText();
input1.setText("");
if((a.equals("12")==true)&&(b.equals("12")==true))
{
prompt2.setText(" 姓名:");
prompt3.setText(" 学号:");
prompt4.setVisible(true);
prompt5.setVisible(true);
input3.setVisible(true);
input4.setVisible(true);
btn2.setVisible(true);
btn3.setVisible(true);
btn4.setVisible(true);
btn3.setEnabled(false);
btn4.setEnabled(false);
btn1.setLabel("查询");
input1.setText("登录成功");
input1.selectAll();
}
else
input2.setText("用户名或密码错");
}
if(e.getActionCommand()=="增加")
{
boolean scucss=true;
try
{
XingMing();
}
catch(EmptyException as)
{
input1.setText("姓名不能为空");
scucss=false;
}
try
{
xh=Integer.parseInt(input2.getText());
}
catch(NumberFormatException m)
{
input2.setText("学号为空或格式错");
scucss=false;
}
bj=input3.getText();
try
{
ChengJi();
}
catch(EmptyException as)
{
cj=-1;
}
catch(OverException dd)
{
input4.setText("应在0-100间");
scucss=false;
}
catch(NumberFormatException cm)
{
input4.setText("成绩应为数据");
scucss=false;
}
if(scucss==true)
{
SI=new StudentInf(xm,xh,bj,cj);
Insert(SI);
}
}
if(e.getActionCommand()=="修改")
{
xm=input1.getText();
xh=Integer.parseInt(input2.getText());
bj=input3.getText();
cj=Integer.parseInt(input4.getText());
SI=new StudentInf(xm,xh,bj,cj);
StuInf.setElementAt(SI, mid);
btn3.setEnabled(false);
}
if(e.getActionCommand()=="删除")
{
StuInf.removeElementAt(mid);
btn4.setEnabled(false);
input1.setText("删除成功");
input2.setText("");
input3.setText("");
input4.setText("");
}
if(e.getActionCommand()=="查询")
{
boolean right=true;
try
{
xh=Integer.parseInt(input2.getText());
}
catch(NumberFormatException m)
{
input2.setText("学号为空或格式错");
right=false;
}
if(right==true)
{
search(xh);
btn3.setEnabled(true);
btn4.setEnabled(true);
}
}
}
//查找方法
public void search(int k)
{
boolean exist=false;
int low=0;
int high=StuInf.size()-1;
while(low<=high)
{
mid=(high+low)/2;
StudentInf a1=(StudentInf) StuInf.elementAt(mid);
if(a1.getStuNo()==k)
{
SI=(StudentInf) StuInf.elementAt(mid);
String x = String.valueOf(SI.getStuNo());
exist=true;
input1.setText(SI.getname());
input1.selectAll();
input2.setText("0"+x);
input3.setText(SI.getClassNo());
if(SI.getLevel()==-1)
input4.setText("未参加考试");
else
{
String y = String.valueOf(SI.getLevel());
input4.setText(y);
}
break;
}
else if(a1.getStuNo()<k)
low=mid+1;
else
high=mid-1;
}
if(exist==false)
{
input1.setText("无此学号学生信息");
input1.selectAll();
}
}
//添加方法
public void Insert(StudentInf q)
{
int i=0;
if(StuInf.isEmpty()==true)
{
StuInf.addElement(q);
input1.setText("");
input2.setText("");
input3.setText("");
input4.setText("");
}
else
{
StudentInf xh;
xh=(StudentInf) StuInf.firstElement();
while(xh.getStuNo()<q.getStuNo())
{
i++;
if(i<StuInf.size())
xh=(StudentInf) StuInf.elementAt(i);
else
break;
}
if(xh.getStuNo()==q.getStuNo())
{
input2.setText("此学生信息已存在");
input2.requestFocus();
input2.selectAll();
}
else
{
StuInf.insertElementAt(q,i);
input1.setText("");
input2.setText("");
input3.setText("");
input4.setText("");
}
}
}
//异常类
class OverException extends Exception
{
String over;
}
class EmptyException extends Exception
{
String empty;
}
void XingMing() throws EmptyException
{
if((input1.getText()).equals(""))
throw (new EmptyException());
else
xm=input1.getText();
}
void ChengJi() throws OverException,EmptyException
{
if((input4.getText()).equals(""))
throw(new EmptyException());
else
cj=Integer.parseInt(input4.getText());
if(cj<0||cj>100)
throw (new OverException());
}
//学生信息类
public class StudentInf
{
private String name;
private int StuNo;
private String ClassNo;
private int Level;
StudentInf(String xingming,int xuehao,String banji,int chengji)
{
name=xingming;
StuNo=xuehao;
ClassNo=banji;
Level=chengji;
}
public int getStuNo()
{
return StuNo;
}
public String getname()
{
return name;
}
public String getClassNo()
{
return ClassNo;
}
public int getLevel()
{
return Level;
}
}
}
分享到:
相关推荐
java做的一个学生成绩系统.zip
java语言课程设计学生成绩管理系统项目源码java语言课程设计学生成绩管理系统项目源码java语言课程设计学生成绩管理系统项目源码java语言课程设计学生成绩管理系统项目源码。java语言课程设计学生成绩管理系统项目...
JAVA学生成绩管理系统(源码+数据库)JAVA学生成绩管理系统(源码+数据库)JAVA学生成绩管理系统(源码+数据库)JAVA学生成绩管理系统(源码+数据库)JAVA学生成绩管理系统(源码+数据库)JAVA学生成绩管理系统...
这是一个基于springboot+vue+mybatis的学生成绩管理系统。java开发基于springboot的管理系统源码。这是一个基于springboot+vue+mybatis的学生成绩管理系统。java开发基于springboot的管理系统源码。这是一个基于...
java做的一个学生成绩系统,互联网的兴起从本质上改变了整个社会的商品交易方式,国内各大企业从20世纪90年代互联网兴起之时,就产生了通过网络进行销售经营的想法。
基于JAVA的学生成绩管理系统的设计与实现 摘 要:本文按照目前流行的B/S体系结构模式,结合现有的学生成绩管理系统的现状,采用 SQL Server 2000数据库和JAVA技术,设计开发了学生成绩管理系统系统,本系统分为前台...
JAVA数据库学生成绩管理系统实验报告.pdfJAVA数据库学生成绩管理系统实验报告.pdfJAVA数据库学生成绩管理系统实验报告.pdfJAVA数据库学生成绩管理系统实验报告.pdfJAVA数据库学生成绩管理系统实验报告.pdfJAVA数据库...
【JAVA】GUI+控制台双程序 学生成绩管理系统,涉及java swing库JMeauBar菜单栏,JTable表格的增删改查,JButton事件绑定,和各种按钮事件的绑定
本项目是一套基于java Swing开发的学生成绩管理系统,主要针对计算机相关专业的正在做bishe的学生和需要项目实战练习的Java学习者。 包含:项目源码、数据库脚本等,该项目可以直接作为bishe使用。 项目都经过严格...
可运行的用Java编写的学生成绩管理系统,学生课程设计可用作参考
Java+MySQL开发的《学生成绩管理系统》毕业设计,系统采用java为编程语言,mysql为数据库,采用html为作为前端显示,采用B/S架构,避免了安装等步骤。此系统能够实现学生、老师、课程、老师授课等信息的添加,能够对...
学生成绩管理系统Java课程设计.pdf学生成绩管理系统Java课程设计.pdf学生成绩管理系统Java课程设计.pdf学生成绩管理系统Java课程设计.pdf学生成绩管理系统Java课程设计.pdf学生成绩管理系统Java课程设计.pdf学生成绩...
任何系统都要遵循系统设计的基本流程,本系统也不例外,同样需要经过市场调研,需求分析,概要设计,详细设计,编码,测试这些步骤,基于java语言设计并实现了学生成绩管理系统。该系统基于B/S即所谓浏览器/服务器...
java课程设计-学生成绩管理系统设计报告
写一个小程序:学生管理系统。需求是学生信息录入:姓名,学号,班级,以及其他信息,针对不同课程,建立不同的成绩录入方法。需要注意同一学生,可能会有不同的课程,以及不同课程,总成绩方法计算方式不一样,输入的...
java+SQLServer学生成绩管理系统(代码+数据库)
JAVA学生成绩管理系统课程设计报告
用java做的成绩管理系统 跟大家分享一下