用java编写学生管理系统

作者&投稿:检信 (若有异议请与网页底部的电邮联系)
求用Java编写的学生成绩管理系统的完整代码,要能运行的~

以下方法实现了用户界面登陆
import java.awt.*;
import java.awt.event.*;
public class DengLuJieMian extends Frame implements ActionListener
{
Label username=new Label("用户名:");//使用文本创建一个用户名标签
TextField t1=new TextField();//创建一个文本框对象
Label password=new Label("密码:");//创建一个密码标签
TextField t2=new TextField();
Button b1=new Button("登陆");//创建登陆按钮
Button b2=new Button("取消");//创建取消按钮
public DengLuJieMian()
{
this.setTitle("学生信息管理系统");//设置窗口标题
this.setLayout(null);//设置窗口布局管理器
username.setBounds(50,40,60,20);//设置姓名标签的初始位置
this.add(username);// 将姓名标签组件添加到容器
t1.setBounds(120,40,80,20);// 设置文本框的初始位置
this.add(t1);// 将文本框组件添加到容器
password.setBounds(50,100,60,20);//密码标签的初始位置
this.add(password);//将密码标签组件添加到容器
t2.setBounds(120,100,80,20);//设置密码标签的初始位置
this.add(t2);//将密码标签组件添加到容器
b1.setBounds(50,150,60,20);//设置登陆按钮的初始位置
this.add(b1);//将登陆按钮组件添加到容器
b2.setBounds(120,150,60,20);//设置取消按钮的初始位置
this.add(b2);// 将取消按钮组件添加到容器
b1.addActionListener(this);//给登陆按钮添加监听器
b2.addActionListener(this);// 给取消按钮添加监听器

this.setVisible(true);//设置窗口的可见性
this.setSize(300,200);//设置窗口的大小
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});//通过内部类重写关闭窗体的方法
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==b1)//处理登陆事件
{
String name=t1.getText();
String pass=t2.getText();
if(name!=null&&pass.equals("000123"))//判断语句
{
new StudentJieMian();
}
}
}
public static void main(String args[])//主函数
{
new DengLuJieMian();
}
}
以下方法实现了学生界面设计
import java.awt.*;
import java.awt.event.*;
class StudentJieMian extends Frame implements ActionListener
{
MenuBar m=new MenuBar();//创建菜单栏
Menu m1=new Menu("信息");//创建菜单“信息”
MenuItem m11=new MenuItem("插入");//创建“插入”的菜单项
MenuItem m12=new MenuItem("查询");
Menu m2=new Menu("成绩");//创建菜单“成绩”
MenuItem m21=new MenuItem("查询");
public StudentJieMian()
{
this.setTitle("学生界面");//设置窗口标题
this.setLayout(new CardLayout());//设置窗口布局管理器
this.setMenuBar(m);//将菜单栏组件添加到容器
m.add(m1);//将信息菜单放入菜单栏
m.add(m2);
m1.add(m11);//将“插入”菜单项添加到“信息”菜单
m1.add(m12); //将“查询”菜单项添加到“信息”菜单
m2.add(m21); //将“查询”菜单项添加到“成绩”菜单
m11.addActionListener(this); //给“插入”菜单项添加监听器
m12.addActionListener(this); //给“查询”菜单项添加监听器
m21.addActionListener(this); //给“查询”菜单项添加监听器
this.setVisible(true); //设置窗口的可见性
this.setSize(300,200); //设置窗口的大小
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);//关闭窗口
}
});
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==m11) //处理“添加信息”事件
{
new AddStudent();
}
if(e.getSource()==m12) //处理“查询信息”事件
{
new SelectStudent();
}
if(e.getSource()==m21) //处理“查询成绩”事件
{
new ChengJiStudent();
}
}
public static void main(String args[])
{ new StudentJieMian(); //创建一个对象 }

import java.util.*;import java.io.*;class StuMgr{public static class Student{public int id;public String name;public int age;public Student(int id ,String name,int age){this.id = id;this.name = name;this.age = age;}@Overridepublic String toString(){return id + "," + name + "," + age;}}public List stuList = new LinkedList();public void add(){Scanner sc = new Scanner(System.in); System.out.println("请输入学生学号:");String id = sc.nextLine();int intId = 0;try{intId = Integer.parseInt(id);}catch(NumberFormatException ex){System.out.println("学号输入有误,请输入数字!");return;}if (find(intId) != null){System.out.println("该学号已经存在!");return ;}System.out.println("请输入学生姓名:");String name = sc.nextLine();System.out.println("请输入学生年龄:");String age = sc.nextLine();int intAge = 0;try{intAge = Integer.parseInt(age);}catch(NumberFormatException ex){System.out.println("年龄输入有误,请输入数字!");return;}Student stu = new Student(intId,name,intAge);stuList.add(stu);store();System.out.println("-----------------------");System.out.println("学生信息已增加");System.out.println(stu);System.out.println("-----------------------");}public void del(){Scanner sc = new Scanner(System.in); System.out.println("请输入学生学号:");String id = sc.nextLine();int intId = 0;try{intId = Integer.parseInt(id);}catch(NumberFormatException ex){System.out.println("学号输入有误,请输入数字!");return;}Student stu = find(intId);if ( stu == null){System.out.println("该学号不存在!");return ;}stuList.remove(stu);store();System.out.println("-----------------------");System.out.println("学生信息已删除");System.out.println(stu);System.out.println("-----------------------");}public void find(){Scanner sc = new Scanner(System.in); System.out.println("请输入学生学号:");String id = sc.nextLine();int intId = 0;try{intId = Integer.parseInt(id);}catch(NumberFormatException ex){System.out.println("学号输入有误,请输入数字!");return;}Student stu = find(intId);if ( stu == null){System.out.println("该学号不存在!");return ;}System.out.println("-----------------------");System.out.println("查找学生信息如下");System.out.println(stu);System.out.println("-----------------------");}public Student find(int id){for(Student stu : stuList){if(stu.id == id){return stu;}}return null;}public void modify(){store();}public void foreach(){System.out.println("-----------------------");for(Student stu : stuList){System.out.println(stu);}System.out.println("-----------------------");}public void store(){Iterator iterator = stuList.iterator();File file = new File("stuList.txt"); FileWriter fw = null; BufferedWriter writer = null; try { fw = new FileWriter(file); writer = new BufferedWriter(fw); while(iterator.hasNext()){ writer.write(iterator.next().toString()); writer.newLine();//换行 } writer.flush(); } catch (FileNotFoundException e) { e.printStackTrace(); }catch (IOException e) { e.printStackTrace(); }finally{ try { writer.close(); fw.close(); } catch (IOException e) { e.printStackTrace(); } }}public static void main(String[] args){StuMgr mgr = new StuMgr();while(true){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("6:退出");System.out.println("-----------------------");Scanner sc = new Scanner(System.in); String op = sc.nextLine();if("6".equals(op)){return;}if("1".equals(op)){mgr.add();}if("2".equals(op)){mgr.del();}if("3".equals(op)){mgr.find();}if("4".equals(op)){mgr.modify();}if("5".equals(op)){mgr.foreach();}}}}时间仓促,还有一个modify方法没实现,留给你自己练手。

package com.tree;

import java.util.Arrays;

public class StudentDemo {

private int[] temp;

public StudentDemo(int[] temp) {
this.temp = temp;
}

public void printAllGrade() {
if (temp != null) {
for (int i = 0; i < temp.length; i++) {
System.out.println("学号 " + (i + 1) + ":" + temp[i]);
}
} else {
System.out.println("参数有误!");
}
}

public void printAvarage() {
if (temp != null) {
Arrays.sort(temp);// 排序数据
double sum=0.00;
for (int i = 0; i < temp.length; i++) {
sum+=temp[i];
}
System.out.println("平均分 :" + sum/temp.length);
System.out.println("最高分 :" + temp[temp.length-1]);
System.err.println("最低分 :" + temp[0]);

} else {
System.out.println("参数有误!");
}

}

public void printDistribution(){
if(temp!=null){
Arrays.sort(temp);// 排序数据
StringBuffer a10 = new StringBuffer();//00-09
StringBuffer a20 = new StringBuffer();//10-19
StringBuffer a30 = new StringBuffer();//20-29
StringBuffer a40 = new StringBuffer();//30-39
StringBuffer a50 = new StringBuffer();//40-49
StringBuffer a60 = new StringBuffer();//50-59
StringBuffer a70 = new StringBuffer();//60-69
StringBuffer a80 = new StringBuffer();//70-79
StringBuffer a90 = new StringBuffer();//80-89
StringBuffer a99 = new StringBuffer();//90-99
StringBuffer a100 = new StringBuffer();//一百分;
for (int i = 0; i < temp.length; i++) {
if (temp[i] < 10) {
a10.append("*");
} else if (temp[i] < 20) {
a20.append("*");
} else if (temp[i] < 30) {
a30.append("*");
} else if (temp[i] < 40) {
a40.append("*");
} else if (temp[i] < 50) {
a50.append("*");
} else if (temp[i] < 60) {
a60.append("*");
} else if (temp[i] < 70) {
a70.append("*");
} else if (temp[i] < 80) {
a80.append("*");
} else if (temp[i] < 90) {
a90.append("*");
} else if(temp[i] <100){
a100.append("*");
}else {
a100.append("*");
}
}
System.out.println("00-09: "+a10);
System.out.println("10-19: "+a20);
System.out.println("20-29: "+a30);
System.out.println("30-39: "+a40);
System.out.println("40-49: "+a50);
System.out.println("50-59: "+a60);
System.out.println("60-69: "+a70);
System.out.println("70-79: "+a80);
System.out.println("80-89: "+a90);
System.out.println("90-99: "+a99);
System.out.println("100:"+a100);
}else{
System.out.println("参数有误!");
}

}

public static void main(String[] args) {
int[] gradesArray = { 87, 68, 94, 100, 83, 78, 85, 91, 76, 87 };
StudentDemo s = new StudentDemo(gradesArray);
s.printAllGrade();
s.printDistribution();
s.printAvarage();

}

}

printMax() 输出学生的最高成绩 和 printMin() 输出学生的最低成绩 我为了方便就直接放到printAvarage()里面了,你自己看下就明白;

这题太简单了,给分吧;

学籍管理系统

#include<iostream.h>

#include<string.h>

#include<iomanip.h>

#include<fstream.h>

#include<stdio.h>

#include<stdlib.h>

class student

{

protected:

int maxnum;

int sno;//学号

char name[5];

char sex[2];

int age;

char birth[10];

char folk[2];//民族

char mianmao[10];//面貌

char department[10];//系别

char banji;

char speciality[10];//专业

char telephone[10];

char address[30];

public:

student();//构造函数

~student();

void enter();

void display();

void setsno(int temp);

int getsno();

char *getname();

long getbanji();

char *getspeciality();//专业

void change();

void read();

void write();

};

student::student()

{}

student::~student()

{}

int student::getsno()

{return sno;}

char *student::getspeciality()

{return speciality;}

long student::getbanji()

{return banji;}

char *student::getname()

{return name;}

void student::setsno(int temp)

{sno=temp;}

class stu:public student

{public:<br/><br/> void search()<br/><br/>{<br/><br/>cout<<"请输入你的查找类型:(1.学号 2.姓名 3.专业 4.班级)"<<endl;<br/><br/>int k,i,m=0;<br/><br/>char j,ch1[5],ch2[10];<br/><br/>cin>>j;<br/><br/>while((j!='1')&&(j!='2')&&(j!='3')&&(j!='4'))<br/><br/>{ cout<<"错误请重新选择!"<<endl;<br/><br/>cin>>j;<br/><br/>}

if(j=='1')

{

cout<<"请输入你要查找的学生的学号:"<<endl;

cin>>i;

}

if(j=='2')

{

cout<<"请输入你要查找的学生的姓名:"<<endl;

cin>>ch1;

}

if(j=='3')

{

cout<<"请输入你要查找的学生所学的专业:"<<endl;

cin>>ch2;

}

if(j=='4')

{

cout<<"请输入你要查找的学生所在的班级:"<<endl;

cin>>k;

}

ifstream dfile("student.txt",ios::nocreate);//打开student文件

while (dfile.good())//

{

dfile.read((char *) &information,sizeof information);

if(i==information.getsno()||strcmp(information.getname(),ch1)==0||

strcmp(information.getspeciality(),ch2)==0||k==information.getbanji())//比较语句

{cout<<"你要查找的学生信息如下:"<<endl;<br/><br/>cout<<setw(4)<<"学号"<<setw(4)<<"姓名"<<setw(4)<<"性别"<<setw(4)<<<br/><br/>"年龄"<<setw(4)<<"民族"<<setw(8)<<"出生日期"<<<br/><br/>setw(8)<<"政治面貌"<<setw(8)<<"系别"<<setw(8)<<"班级"<<setw(8)<br/><br/><<"专业"<<setw(8)<<"联系电话"<<setw(8)<<"家庭住址"<<endl;<br/><br/>information.display();<br/><br/>i=0;//重新赋值<br/><br/>k=0;//重新赋值<br/><br/>m=1;//重新赋值 <br/><br/>return;<br/><br/>}

}

if(m!=1)

cout<<"没有找到这名学生的信息!"<<endl;

};

}information;

//定义enter函数

void student::enter()

{

ifstream tfile("max.txt",ios::binary|ios::nocreate);

if(tfile)

{

tfile.read((char *)&maxnum,sizeof maxnum);//读出信息(即学号)

}

else

{

maxnum=1000;//???否则默认定义为1000

}

tfile.close();

sno=maxnum++;

ofstream ofile("max.txt");

这不难,

用点心就知道了..遇到问题你以问..

没难度 自己研究去


自学Java 怎么入门?
JavaSE基础是Java中级程序员的起点,是帮助你从小白到懂得编程的必经之路。 在Java基础板块中有6个子模块的学习:基础语法,可帮助你建立基本的编程逻辑思维;面向对象,以对象方式去编写优美的Java程序;集合,后期开发中存储数据必备技术;IO,对磁盘文件进行读取和写入基础操作;多线程与并发,提高程序效率;异常,编写代码逻辑...

现在java现在发展前景怎么样?
5、进行游戏开发。有不少游戏都是用java来编写的,如果对游戏比较感兴趣,这也是个不错的选择。6、Java大数据开发。现在大数据这个词还是比较火爆的,如果选择java与大数据相结合也是一个非常好的发展方向。这么看来,学java的就业方向有这六大类,能就业的领域和公司也是十分宽泛的,所以现在乃至未来几年的...

如何从零开始学Java?
随着社会信息的发展,Java技术已经无处不在,无论是手机软件、手机Java游戏还是电脑软件等,只要你使用到电子产品就会碰到和Java有关的东西,更多的企业正采用Java语言开发网站,而在所有程序员中,Java开发工程师就占据20%的比例,不可否认,Java语言有着广泛的行业发展前景,它在行业中的影响力已是不可...

学习Java需要学哪些内容?
学习Java之前先了解这些:第一:在如今这个Java的市场下,你如果太过于着急找工作而去学习,你一定找不到,有一个很简单的道理,任何东西求快没有用,首先你要把技术学的熟练。而不是指望自己看看视频,就能拿到高薪的工作。第二:如果没有一套系统的学习路线和方案,这看看,那里看看,依旧学了之后...

java要学习多久?
零基础学习java编程所需要的时间是受很多因素影响的,比如,你自身的学历,学习态度,是自学还是培训等,所以无法用一个确定的时间段来进行评估。对于零基础的学生来说,想学好java编程,参加专业的软件编程培训是很有必要的。专业的软件学校都是因材施教,针对不同的人群开设不同的班级,学的时间也有所...

全国排名前十的JAVA培训机构有哪些?
Java可以编写桌面应用程序、Web应用程序、分布式系统和嵌入式系统应用程序等。java培训更推荐千锋教育,千锋是一家拥有核心教研能力以及校企合作能力的职业教育培训企业,2011年成立于北京,秉承“初心至善匠心育人”的核心价值观,以坚持面授的泛IT职业教育培训为根基,发展至今已布局教育培训、高校服务、企业服务...

Java如何学习?
Java是一种面向对象的编程语言,任何功能都需要通过编写代码程序来实现,一般在有开设信息技术类相关课程的大学可能会教授一些Java基础内容,但反之对于偏文科类的学校或专业的学生来说,Java对于他们是很陌生的,甚至一无所知。那么Java如何学习呢?下面就跟随北大青鸟霍营计算机学院一起来看看吧。一、学习Java...

JAVA的学习方法
JAVA的学习方法任何事物都有一定的规律性,遵循其规律则成,违背其规律则败,学生学习也是如此,它是一个由浅入深,由少到多,逐步积累,逐步深入,螺旋式提高的过程。遵循学习规律,得学习方法者,会收到事半功倍的

计算机专业学生应具备哪些素质结构?
1、思想道德素质。具有科学的世界观、人生观和道德观,有明确的是非观念;具有爱国主义、集体主义精神,有良好的敬业、创新意识。2、文化素质。 具有高等数学、程序设计、数据处理等理工科知识,有一定的科学素养;具有必要的哲学、法律、职业道德等人文社科知识,有一定的文化素养。3、业务素质。掌握计算机...

Java游戏高级编程的前 言
调幅广告可以使用强大的通用编程语言(例如Java)编写的这个事实,充分发掘它们超越动画的辅助功能的潜能,包括活动数据连接。在仿真领域,学生和科学家都可以从可视化上获益。当这些模型使用Java表示的时候,用户就可以与它们进行交互、更改参数并观察新的结果。读者对象本书专门针对具有丰富经验、正准备和渴望将...

淇滨区13754169323: 怎么用java实现一个简单的学生管理系统 -
霜虾创伤: 用java写的话,可以用List来实现学生管理系统: 首先,管理系统是针对学生对象的,所以我们先把学生对象就写出来: package bean; public class Student {String name;String studentId;String sex;int grade;public Student(String name,...

淇滨区13754169323: 求大神 如何用java 写一个学生管理系统. 急用......... -
霜虾创伤: 首先. 写一个学生类.public class student { private String name; private String age; private String score; public String getName() { return name; } public void setName(String name) { this.name = name; } public String getAge() { return age; } public ...

淇滨区13754169323: java写学生学生管理系统 -
霜虾创伤: 内容较多,你先自己用一下,感受感受,请看实例:User类:public class User { private int id; private String name; private String password; private Course[] courses; private int role; //0老师,1学生 public int total(){ int total=0; if(role==1 && courses!...

淇滨区13754169323: java 学生管理系统怎么写? -
霜虾创伤: 1.awt /swing 2.jsp+java

淇滨区13754169323: 简单的java学生信息管理系统 -
霜虾创伤: package bean; public class Student { String name; String studentId; String sex; int grade; public Student(String name,String studentId,String sex,int grade){ this.name= name; this.studentId= studentId; this.sex = sex; this.grade = grade; } public int ...

淇滨区13754169323: 用java面向对象做学员管理系统
霜虾创伤: 首先 Student stu[]=new Student[100]; 只是定义了 一个引用的数组stu数组里放的是指向null的空的引用 并不指向Student的实例 因为你没有new Student(); 运行时 会报空指针异常 你应该 在前面new一个Student stu[0] = new Student(); stu[0]....

淇滨区13754169323: 用java基础编写一个简单的学生管理系统,有如下功能,添加学生,删除学生,查询学生.看好是用JAVA基础. -
霜虾创伤: 我这里刚刚有一个“网上考试系统”,大三时候Java的考试,非桌面程序,是Web程序,用的都是Java基础,功能除了你所说的对学生的增删改查(包含在系统的考生管理模块里面)以外,还包括对试题的操作,笔试成绩的录入,后门程序修改...

淇滨区13754169323: Java设计开发一个简单的学生管理系统! -
霜虾创伤: 如果是你一个人开发,那就照着需求一步步做呗.比如:首先要有登录界面,登录界面设计好,需要传入的参数有 用户名,密码,登录身份;这时你就设计一个数据库表 user(login_name,login_password,login_type);这时候登录进去,因为不...

淇滨区13754169323: 使用java语言连接数据库编写一个简单的学生信息管理系统 -
霜虾创伤: public static void findInfo(String filePath) throws IOException { //把之前存入到数据的文件,读取到集合中来. ArrayList<Student> list = new ArrayList<Student>(); readData(list,filePath); //遍历集合 for(int i=0;i<list.size();i++) { Student stu = list.get(i);...

淇滨区13754169323: 如何用Java语言编写学生成绩管理系统 -
霜虾创伤: package student; import java.util.Scanner; public class teststudent { public static void main(String args[]){ System.out.println("************************学生成绩管理系统*********************"); System.out.println("请输入要管理的学生人数:")...

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 星空见康网