资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

学生信息系统java代码 学生信息系统java代码查询

.给出存储班级三十名学生基本信息的Java代码,基本信息的具体赋值由考生自拟?

下面是一个存储班级三十名学生基本信息的 Java 代码示例:

创新互联公司是专业的龙岗网站建设公司,龙岗接单;提供成都网站制作、成都网站建设,网页设计,网站设计,建网站,PHP网站建设等专业做网站服务;采用PHP框架,可快速的进行龙岗网站开发网页制作和功能扩展;专业做搜索引擎喜爱的网站,专业的做网站团队,希望更多企业前来合作!

import java.util.ArrayList;

public class Student {

private String name;

private int age;

private String gender;

public Student(String name, int age, String gender) {

this.name = name;

this.age = age;

this.gender = gender;

}

public String getName() {

return name;

}

public int getAge() {

return age;

}

public String getGender() {

return gender;

}

}

public class Classroom {

private ArrayListStudent students;

public Classroom() {

this.students = new ArrayListStudent();

}

public void addStudent(Student student) {

students.add(student);

}

public ArrayListStudent getStudents() {

return students;

}

}

public class Main {

public static void main(String[] args) {

Classroom classroom = new Classroom();

// 添加 30 名学生的基本信息

classroom.addStudent(new Student("Tom", 18, "Male"));

classroom.addStudent(new Student("Alice", 19, "Female"));

// ...

// 此处省略 28 名学生的信息

// 获取所有学生的信息

ArrayListStudent students = classroom.getStudents();

for (Student student : students) {

System.out.println("Name: " + student.getName());

System.out.println("Age: " + student.getAge());

System.out.println("Gender: " + student.getGender());

}

}

}

该代码定义了两个类:Student 类表示一个学生,包含了学生的姓名、年龄和性别等信息;Classroom 类表示一个班级,包含了一个学生的列表,并提供了添加学生和获取学生列表的方法。

在 Main 类的 main 方法中,我们首先实例化一个 Classroom 对象,然后依次添加 30 名学生的信息。最后,我们调用 getStudents 方法获取所

用java编写学生信息系统。请帮我完成代码(要使程序能够实现插入照片和音乐的功能),需要用列表

Connection conn;

try {

Class.forName("oracle.jdbc.driver.OracleDriver");

conn = DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:1521:taian", "hr", "hr"); //连接Oracle

conn.setAutoCommit(false);

Statement myStat = conn.createStatement();

String sqlTxt = "update BankAccount set account=account-" + this.amount.getText() + " where accId=" + this.payOut.getText();

System.out.println("第步 执行:" + sqlTxt);

// 汇扣减

try {

int affectedRow = myStat.executeUpdate(sqlTxt);

System.out.println("汇扣减" + this.amount.getText() + "元,修改" + affectedRow + "行数据.");

sqlTxt = "update BankAccount set account=account+" + this.amount.getText() + " where accId=" + this.saveIn.getText();

System.out.println("第二步 执行:" + sqlTxt);

affectedRow = myStat.executeUpdate(sqlTxt);

System.out.println("汇入增加" + this.amount.getText() + "元,修改" + affectedRow + "行数据.");

// 事务功结束, 提交

conn.commit();

} catch (SQLException sqlEx) {

System.out.println("耶!语句写错吧");

sqlEx.printStackTrace();

// 事务断,整体滚事务始前状态

conn.rollback();

}

// 汇入增加帐户余额

myStat.close();

conn.close();

} catch (Exception ex) {

System.out.println("反错.");

}

}//

求java中类似学生信息管理系统中按学号,按姓名排序的代码

import java.util.ArrayList;

import java.util.Collections;

import java.util.Comparator;

import java.util.List;

public class Sort {

public static void main(String[] args) {

Student p1 = new Student(1001, "小明", 20);

Student p2 = new Student(1002, "小红", 21);

Student p3 = new Student(1003, "小黑", 19);

ListStudent list = new ArrayListStudent();

list.add(p1);

list.add(p2);

list.add(p3);

Collections.sort(list, new ComparatorStudent() {

/*

 * int compare(Student o1, Student o2) 返回一个基本类型的整型, 返回负数表示:o1 小于o2,

 * 返回0 表示:o1和o2相等, 返回正数表示:o1大于o2。

 */

public int compare(Student o1, Student o2) {

// 按照学生的学号进行升序排列

if (o1.getId()  o2.getId()) {

return 1;

}

if (o1.getId() == o2.getId()) {

return 0;

}

return -1;

}

});

write(list);

System.out.println("---------------------");

Collections.sort(list, new ComparatorStudent() {

/*

 * int compare(Student o1, Student o2) 返回一个基本类型的整型, 返回负数表示:o1 小于o2,

 * 返回0 表示:o1和o2相等, 返回正数表示:o1大于o2。

 */

public int compare(Student o1, Student o2) {

// 按照学生的年龄进行升序排列

if (o1.getAge()  o2.getAge()) {

return 1;

}

if (o1.getAge() == o2.getAge()) {

return 0;

}

return -1;

}

});

write(list);

}

public static void write(ListStudent list) {

for (Student s : list) {

System.out.println(s.getId() + "\t" + s.getName() + "\t"

+ s.getAge());

}

}

}

public class Student {

private int id ;

private String name;

private int age;

//构造方法

public Student(int id,String name,int age){

this.id = id;

this.name = name;

this.age = age;

}

public int getId() {

return id;

}

public void setId(int id) {

this.id = id;

}

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

public int getAge() {

return age;

}

public void setAge(int age) {

this.age = age;

}

}

用JAVA编写一个学生信息系统

如果是学生管理系统,

可以从新生入学,学籍档案管理,奖惩、活动、教育履历,成绩管理,分班、专业等角度分析设计与开发。

关键字:java , 信息 , 信息系统 , 学生 , 系统 ,

友情提示:预付定金是诈骗

用java编写学生信息管理系统

仅仅给你个参考

//Java Group Project_StudentManagement源码

//NetBeans IDE 6.5 环境

package studentmanager;

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

import java.io.*;

import java.util.*;

class Student implements java.io.Serializable{

String number,name,specialty,grade,borth,sex;

public Student(){};

public void setNumber(String number)

public String getNumber()

public void setName(String name)

public String getName()

public void setSex(String sex)

public String getSex()

public void setSpecialty(String specialty)

public String getSpecialty()

public void setGrade(String grade)

public String getGrade()

public void setBorth(String borth)

public String getBorth()

}

public class StudentManager extends JFrame{

JLabel lb=new JLabel("录入请先输入记录,查询、删除请先输入学号,修改是对查询" +

"内容改后的保存!");

JTextField 学号,姓名,专业,年级,出生;

JRadioButton 男,女;

ButtonGroup group=null;

JButton 录入,查询,删除,修改,显示;

JPanel p1,p2,p3,p4,p5,p6,pv,ph;

Student 学生=null;

Hashtable 学生散列表=null;

File file=null;

FileInputStream inOne=null;

ObjectInputStream inTwo=null;

FileOutputStream outOne=null;

ObjectOutputStream outTwo=null;

public StudentManager(){

super("学生基本信息管理系统");

学号=new JTextField(10);

姓名=new JTextField(10);

专业=new JTextField(10);

年级=new JTextField(10);

出生=new JTextField(10);

group=new ButtonGroup();

男=new JRadioButton("男",true);

女=new JRadioButton("女",false);

group.add(男);

group.add(女);

录入=new JButton("录入");

查询=new JButton("查询");

删除=new JButton("删除");

修改=new JButton("修改");

显示=new JButton("显示");

录入.addActionListener(new InputAct());

查询.addActionListener(new InquestAct());

修改.addActionListener(new ModifyAct());

删除.addActionListener(new DeleteAct());

显示.addActionListener(new ShowAct());

修改.setEnabled(false);

p1=new JPanel();

p1.add(new JLabel("学号:",JLabel.CENTER));

p1.add(学号);

p2=new JPanel();

p2.add(new JLabel("姓名:",JLabel.CENTER));

p2.add(姓名);

p3=new JPanel();

p3.add(new JLabel("性别:",JLabel.CENTER));

p3.add(男);

p3.add(女);

p4=new JPanel();

p4.add(new JLabel("专业:",JLabel.CENTER));

p4.add(专业);

p5=new JPanel();

p5.add(new JLabel("年级:",JLabel.CENTER));

p5.add(年级);

p6=new JPanel();

p6.add(new JLabel("出生:",JLabel.CENTER));

p6.add(出生);

pv=new JPanel();

pv.setLayout(new GridLayout(6,1));

pv.add(p1);

pv.add(p2);

pv.add(p3);

pv.add(p4);

pv.add(p5);

pv.add(p6);

ph=new JPanel();

ph.add(录入);

ph.add(查询);

ph.add(修改);

ph.add(删除);

ph.add(显示);

file=new File("学生信息.txt");

学生散列表=new Hashtable();

if(!file.exists()){

try{

FileOutputStream out=new FileOutputStream(file);

ObjectOutputStream objectOut=new ObjectOutputStream(out);

objectOut.writeObject(学生散列表);

objectOut.close();

out.close();

}

catch(IOException e){}

}

Container con=getContentPane();

con.setLayout(new BorderLayout());

con.add(lb, BorderLayout.NORTH);

con.add(pv, BorderLayout.CENTER);

con.add(ph, BorderLayout.SOUTH);

setDefaultCloseOperation(EXIT_ON_CLOSE);

setBounds(100,100,600,300);

setVisible(true);

}

public static void main(String[] args)

class InputAct implements ActionListener{

public void actionPerformed(ActionEvent e){

修改.setEnabled(false);

String number="";

number=学号.getText();

if(number.length()0){

try{

inOne=new FileInputStream(file);

inTwo=new ObjectInputStream(inOne);

学生散列表=(Hashtable)inTwo.readObject();

inOne.close();

inTwo.close();

}

catch(Exception ee)

if(学生散列表.containsKey(number)){

String warning="该生信息已存在,请到修改页面修改!";

JOptionPane.showMessageDialog(null,warning,"警告",

JOptionPane.WARNING_MESSAGE);

}//end if1

else{

String m="该生信息将被录入!";

int ok=JOptionPane.showConfirmDialog(null,m,"确认",

JOptionPane.YES_NO_OPTION,JOptionPane.INFORMATION_MESSAGE);

if(ok==JOptionPane.YES_OPTION){

String name=姓名.getText();

String specialty=专业.getText();

String grade=年级.getText();

String borth=出生.getText();

String sex=null;

if(男.isSelected())

else

学生=new Student();

学生.setNumber(number);

学生.setName(name);

学生.setSpecialty(specialty);

学生.setGrade(grade);

学生.setBorth(borth);

学生.setSex(sex);

try{

outOne=new FileOutputStream(file);

outTwo=new ObjectOutputStream(outOne);

学生散列表.put(number,学生);

outTwo.writeObject(学生散列表);

outTwo.close();

outOne.close();

}

catch(Exception ee)

学号.setText(null);

姓名.setText(null);

专业.setText(null);

年级.setText(null);

出生.setText(null);

}

}//end else1

}//end if0

else{

String warning="必须输入学号!";

JOptionPane.showMessageDialog(null,warning,

"警告",JOptionPane.WARNING_MESSAGE);

}//end else0

}//end actionPerformed

}//end class

class InquestAct implements ActionListener{

public void actionPerformed(ActionEvent e){

String number="";

number=学号.getText();

if(number.length()0){

try{

inOne=new FileInputStream(file);

inTwo=new ObjectInputStream(inOne);

学生散列表=(Hashtable)inTwo.readObject();

inOne.close();

inTwo.close();

}

catch(Exception ee)

if(学生散列表.containsKey(number)){

修改.setEnabled(true);

Student stu=(Student)学生散列表.get(number);

姓名.setText(stu.getName());

专业.setText(stu.getSpecialty());

年级.setText(stu.getGrade());

出生.setText(stu.getBorth());

if(stu.getSex().equals("男"))

else

}

else{

修改.setEnabled(false);

String warning="该学号不存在!";

JOptionPane.showMessageDialog(null,warning,

"警告",JOptionPane.WARNING_MESSAGE);

}

}

else{

修改.setEnabled(false);

String warning="必须输入学号!";

JOptionPane.showMessageDialog(null,warning,

"警告",JOptionPane.WARNING_MESSAGE);

}

}

}

class ModifyAct implements ActionListener{

public void actionPerformed(ActionEvent e){

String number=学号.getText();

String name=姓名.getText();

String specialty=专业.getText();

String grade=年级.getText();

String borth=出生.getText();

String sex=null;

if(男.isSelected())

else

Student 学生=new Student();

学生.setNumber(number);

学生.setName(name);

学生.setSpecialty(specialty);

学生.setGrade(grade);

学生.setBorth(borth);

学生.setSex(sex);

try{

outOne=new FileOutputStream(file);

outTwo=new ObjectOutputStream(outOne);

学生散列表.put(number, 学生);

outTwo.writeObject(学生散列表);

outTwo.close();

outOne.close();

学号.setText(null);

姓名.setText(null);

专业.setText(null);

年级.setText(null);

出生.setText(null);

}

catch(Exception ee){

System.out.println("录入修改出现异常!");

修改.setEnabled(false);

}

}

}

class DeleteAct implements ActionListener{

public void actionPerformed(ActionEvent e){

修改.setEnabled(false);

String number=学号.getText();

if(number.length()0){

try{

inOne=new FileInputStream(file);

inTwo=new ObjectInputStream(inOne);

学生散列表=(Hashtable)inTwo.readObject();

inOne.close();

inTwo.close();

}

catch(Exception ee){}

if(学生散列表.containsKey(number)){

Student stu=(Student)学生散列表.get(number);

姓名.setText(stu.getName());

专业.setText(stu.getSpecialty());

年级.setText(stu.getGrade());

出生.setText(stu.getBorth());

if(stu.getSex().equals("男"))

else

}

String m="确定要删除该学生的记录吗?";

int ok=JOptionPane.showConfirmDialog(null,m,"确认",

JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE);

if(ok==JOptionPane.YES_OPTION){

学生散列表.remove(number);

try{

outOne=new FileOutputStream(file);

outTwo=new ObjectOutputStream(outOne);

outTwo.writeObject(学生散列表);

outTwo.close();

outOne.close();

学号.setText(null);

姓名.setText(null);

专业.setText(null);

年级.setText(null);

出生.setText(null);

}

catch(Exception ee)

}

else if(ok==JOptionPane.NO_OPTION){

学号.setText(null);

姓名.setText(null);

专业.setText(null);

年级.setText(null);

出生.setText(null);

}

else{

String warning="该学号不存在!";

JOptionPane.showMessageDialog(null,warning,

"警告",JOptionPane.WARNING_MESSAGE);

}

}

else{

String warning="必须输入学号!";

JOptionPane.showMessageDialog(null,warning,

"警告",JOptionPane.WARNING_MESSAGE);

}

}

}

class ShowAct implements ActionListener{

public void actionPerformed(ActionEvent e){

new StudentShow(file);

}

}

class StudentShow extends JDialog{

Hashtable 学生散列表= null;

JTextArea 显示=null;

FileInputStream inOne=null;

ObjectInputStream inTwo=null;

File file=null;

public StudentShow(File file){

super(new JFrame(),"显示对话框");

this.file=file;

显示=new JTextArea(16,30);

try{

inOne=new FileInputStream(file);

inTwo=new ObjectInputStream(inOne);

学生散列表=(Hashtable)inTwo.readObject();

inOne.close();

inTwo.close();

}

catch(Exception ee){}

if(学生散列表.isEmpty())显示.append("目前还没有学生的信息记录!\n");

else{

显示.setText("学号 姓名 性别 专业 年级 出生\n");

for(Enumeration enm=学生散列表.elements();enm.hasMoreElements();){

Student stu=(Student)enm.nextElement();

String sex="";

if(stu.getSex().equals("男"))sex="男";

else sex="女";

String str=stu.getNumber()+","+stu.getName()+","+sex+","

+stu.getSpecialty()+","+stu.getGrade()+","+stu.getBorth()+"\n";

显示.append(str);

}

}

JScrollPane scroll=new JScrollPane(显示);

Container con=getContentPane();

con.add("Center",scroll);

con.validate();

setVisible(true);

setBounds(200,200,400,300);

addWindowListener(new WindowAdapter(){

public void windowClosing(WindowEvent e)

}

);

}

}

}

求一个用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!=nullpass.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(); //创建一个对象 }


当前题目:学生信息系统java代码 学生信息系统java代码查询
URL地址:http://cdkjz.cn/article/doojdco.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

业务热线:400-028-6601 / 大客户专线   成都:13518219792   座机:028-86922220