网站建设资讯

NEWS

网站建设资讯

java成绩查询代码,java简单学生成绩查询系统

java软件做一个学生成绩查询系统

用易查分就可以做,把你需要查询的信息做成excel表格,上传到易查分,设置“学号”“姓名”为查询条件,设置完成后,点生成,就可以得到一个查询链接,你可以把这个链接放到你所说的网站上,学员点链接 输入学号姓名就能查到!另外如果信息有错误,你可以在易查分的后台,在线编辑,不用再次上传就能实现,非常简单的!

10年积累的成都网站设计、成都网站建设经验,可以快速应对客户对网站的新想法和需求。提供各种问题对应的解决方案。让选择我们的客户得到更好、更有力的网络服务。我虽然不认识你,你也不认识我。但先网站设计后付款的网站建设流程,更有大兴免费网站建设让你可以放心的选择与我们合作。

基于java设计一个学生成绩管理系统,要求有界面,且有增加,查询,修改,删除,退出功能,代码如何写?

import java.awt.Color;

import java.awt.Font;

import java.awt.Frame;

import java.awt.Label;

import java.awt.TextField;

import java.awt.Window;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import java.awt.event.WindowAdapter;

import java.awt.event.WindowEvent;

import java.sql.SQLException;

import javax.swing.JButton;

public class Stmessege {

Font font = new Font("楷体", Font.BOLD, 18);

private Frame m = new Frame("登陆成功界面");

protected Window f;

public Stmessege() {

m.addWindowListener(new WindowAdapter() {

public void windowClosing(WindowEvent evt) {

m.setVisible(false);

m.dispose();

System.exit(0);

}

});

m.setSize(460, 360);

m.setBackground(Color.green);

m.setLayout(null);

m.setLocationRelativeTo(null);

Label l0 = new Label("管理员信息");

Font font1 = new Font("楷体", Font.BOLD, 32);

l0.setForeground(Color.blue);

l0.setSize(180, 50);

l0.setLocation(150, 30);

l0.setFont(font1);

final Label l1 = new Label("姓名:");

l1.setSize(60, 20);

l1.setLocation(10, 100);

l1.setFont(font);

TextField tf1 = new TextField("黄朋");

tf1.setForeground(Color.blue);

tf1.setBackground(Color.white);

tf1.setSize(50, 20);

tf1.setLocation(70, 100);

final Label l2 = new Label("学号:");

l2.setSize(60, 20);

l2.setLocation(140, 100);

l2.setFont(font);

TextField tf2 = new TextField("111265");

tf2.setForeground(Color.blue);

tf2.setBackground(Color.white);

tf2.setSize(60, 20);

tf2.setLocation(190, 100);

final Label l3 = new Label("性别:");

l3.setSize(60, 20);

l3.setLocation(280, 100);

l3.setFont(font);

TextField tf3 = new TextField("男");

tf3.setForeground(Color.blue);

tf3.setBackground(Color.white);

tf3.setSize(40, 20);

tf3.setLocation(360, 100);

final Label l4 = new Label("班级:");

l4.setSize(60, 20);

l4.setLocation(10, 170);

l4.setFont(font);

TextField tf4 = new TextField("611231");

tf4.setForeground(Color.blue);

tf4.setBackground(Color.white);

tf4.setSize(60, 20);

tf4.setLocation(67, 170);

final Label l5 = new Label("系别:");

l5.setSize(60, 20);

l5.setLocation(140, 170);

l5.setFont(font);

TextField tf5 = new TextField("计算机工程系");

tf5.setForeground(Color.blue);

tf5.setBackground(Color.white);

tf5.setSize(80, 20);

tf5.setLocation(200, 170);

final Label l6 = new Label("成绩:");

l6.setSize(60, 20);

l6.setLocation(280, 170);

l6.setFont(font);

TextField tf6 = new TextField("95");

tf6.setForeground(Color.blue);

tf6.setBackground(Color.white);

tf6.setSize(40, 20);

tf6.setLocation(360, 170);

final Label l7 = new Label("专业:");

l7.setSize(60, 20);

l7.setLocation(10, 230);

l7.setFont(font);

TextField tf7 = new TextField("软件技术");

tf7.setForeground(Color.blue);

tf7.setBackground(Color.white);

tf7.setSize(60, 20);

tf7.setLocation(70, 230);

JButton btn1 = new JButton("添加");

btn1.setForeground(Color.blue);

btn1.setSize(80, 38);

btn1.setLocation(35, 300);

btn1.setFont(font);

btn1.addActionListener(new ActionListener() {

@Override

public void actionPerformed(ActionEvent e) {

// TODO Auto-generated method stub

new 插入();

m.setVisible(true);

}

});

JButton btn2 = new JButton("查询学生学籍信息");

btn2.setForeground(Color.blue);

btn2.setSize(200, 38);

btn2.setLocation(135, 300);

btn2.setFont(font);

btn2.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

Stmessege1 f;

try {

f = new Stmessege1();

f.Stmessege11();

m.setVisible(true);

} catch (SQLException e1) {

// TODO Auto-generated catch block

e1.printStackTrace();

} catch (ClassNotFoundException e1) {

// TODO Auto-generated catch block

e1.printStackTrace();

}

}

});

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

btn3.setForeground(Color.blue);

btn3.setSize(80, 38);

btn3.setLocation(350, 300);

btn3.setFont(font);

btn3.addActionListener(new ActionListener() {

@Override

public void actionPerformed(ActionEvent e) {

// TODO Auto-generated method stub

new 删除();

//f.setVisible(false);

m.setVisible(true);

}

});

JButton btn4 = new JButton("更新");

btn4.setForeground(Color.blue);

btn4.setSize(80, 38);

btn4.setLocation(200, 230);

btn4.setFont(font);

btn4.addActionListener(new ActionListener() {

@Override

public void actionPerformed(ActionEvent e) {

// TODO Auto-generated method stub

new 更新();

m.setVisible(true);

}

});

m.add(l0);

m.add(l1);

m.add(tf1);

m.add(l2);

m.add(tf2);

m.add(l3);

m.add(tf3);

m.add(l4);

m.add(tf4);

m.add(l5);

m.add(tf5);

m.add(l6);

m.add(tf6);

m.add(l7);

m.add(tf7);

m.add(btn1);

m.add(btn2);

m.add(btn3);

m.add(btn4);

m.setVisible(true);

}

public static void main(String[] args) {

new Stmessege();

}

}

可以仿照我的做一下,希望采纳,我才一级哦

java实现数据库的链接查询学生成绩! 求代码

可使用jdbc链接。

下面是针对MySql的链接!

-----------------------------------------

package com.dgy.util;

import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.ResultSet;

import java.sql.SQLException;

import java.sql.Statement;

public class TestJDBC {

/**

* 1、所使用的mysql驱动包为mysql-connector-java-5.0.8-bin.jar

* 2、Statement 用于执行静态 SQL 语句并返回它所生成结果的对象

* 在默认情况下,同一时间每个 Statement 对象在只能打开一个 ResultSet 对象。

* 因此,如果读取一个 ResultSet 对象与读取另一个交叉,

* 则这两个对象必须是由不同的Statement 对象生成的。

* 如果存在某个语句的打开的当前 ResultSet 对象,

* 则Statement 接口中的所有执行方法都会隐式关闭它。

* 3、ResultSet 表示数据库结果集的数据表,通常通过执行查询数据库的语句生成。

* ResultSet 对象具有指向其当前数据行的指针。最初,指针被置于第一行之前。

* next 方法将指针移动到下一行;

* 因为该方法在 ResultSet 对象中没有下一行时返回 false,

* 所以可以在 while 循环中 使用它来迭代结果集。

**/

static Connection conn = null;

public static Connection getConnectionByJDBC() {

try {

//装载驱动包类

Class.forName(com.mysql.jdbc.Driver");//加载驱动

}catch(ClassNotFoundException e) {

System.out.println("装载驱动包出现异常!请查正!");

e.printStackTrace();

}

try{

/** 建立jdbc连接,但要注意此方法的第一个参数,

* 如果127.0.0.1出现CommunicationsException异常,

* 可能就需要改为localhost才可以

**/

//jdbc:mysql://localhost:3306/test,test是数据库

conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","123456");

}catch(SQLException e) {

System.out.println("链接数据库发生异常!");

e.printStackTrace();

}

return conn;

}

public static void test(){

String sql = "select * from user";

getConnectionByJDBC();

try{

//创建一个jdbc声明

Statement stmt = conn.createStatement();

//执行查询

ResultSet rs = stmt.executeQuery(sql);

while(rs.next()) {

String username = rs.getString("username");

String password= rs.getString("password");

System.out.println(username +""+ password);

}

}catch (SQLException e){

System.out.println(e.getMessage());

e.printStackTrace();

}finally{

//预防性关闭连接(避免异常发生时在try语句块关闭连接没有执行)

try{

if(conn != null) conn.close();

} catch(SQLException e){

System.out.println(e.getMessage());

e.printStackTrace();

}

}

}

public static void main(String[] args){

TestJDBC testjdbc = new TestJDBC();

testjdbc.test();

}

}

用java学生成绩统计

import java.util.Scanner;

public class Test {

protected static boolean end_flag = true;

public static void main(String[] args) {

Students student = new Students();

student.InputData();// 输入学生数据

String order;

while (end_flag) {

System.out.println("请输入数字1-5:");

Scanner s = new Scanner(System.in);

order = s.nextLine();

student.Operator(order);

}

}

}

Students类:

import java.util.ArrayList;

import java.util.Scanner;

public class Students {

private int STUDENTS_NUM = 5; // 学生的人数

private int SUBJECTS_NUM = 3; // 课程数

private String[][] data = new String[STUDENTS_NUM][SUBJECTS_NUM + 2];

private String name;

private int Chinese_score;

private int Math_score;

private int English_score;

public void SearchHighestScore(String[][] original) { // 查找最高成绩

int flag = Integer.parseInt(original[0][4]), position = 0;

for (int i = 1; i  original.length; i++) {

if (Integer.parseInt(original[i][4])  flag) {

flag = Integer.parseInt(original[i][4]);

position = i;

}

}

System.out.print("最高分同学的姓名和总分为:");

System.out.println(original[position][0] + " " + original[position][4]);

}

public void SearchLowestScore(String[][] original) {

int flag = Integer.parseInt(original[0][4]), position = 0;

for (int i = 1; i  original.length; i++) {

if (Integer.parseInt(original[i][4])  flag) {

flag = Integer.parseInt(original[i][4]);

position = i;

}

}

System.out.print("最低分同学的姓名和总分为:");

System.out.println(original[position][0] + " " + original[position][4]);

}

public void OrderStudents(String[][] original) {

String[][] result = original;

String temp;

for (int i = 1; i  result.length; i++) {

for (int j = 0; j  result.length - i; j++) {

if (Integer.parseInt(result[j][4])  Integer

.parseInt(result[j + 1][4])) {

temp = result[j][4];

result[j][4] = result[j + 1][4];

result[j + 1][4] = temp;

temp = result[j][0];

result[j][0] = result[j + 1][0];

result[j + 1][0] = temp;

}

}

}

System.out.println("排名\t" + "姓名\t" + "总分\t");

for (int i = 0; i  STUDENTS_NUM; i++) {

System.out.println(i + 1 + "\t" + result[i][0] + "\t"

+ result[i][4]);

}

}

public void ScoreUnder60(String[][] original) {

System.out.println("平均分在60以下的学生的姓名为:");

ArrayList temp = new ArrayList();

for (int i = 0; i  original.length; i++) {

if (Integer.parseInt(original[i][4]) / SUBJECTS_NUM  60) {

temp.add(original[i][0]);

}

}

System.out.print(temp + " ");

System.out.println("\n" + "平均分在60以下的学生的人数为:"

+ temp.size());

}

public Integer SearchScore(String student_name) {

int position = -1;

for (int i = 0; i  data.length; i++) {

if (student_name.equals(data[i][0])) {

position = i;

}

}

if (position != -1)

return Integer.valueOf(data[position][4]);

else

return null;

}

public void Operator(String order) {

if ("1".equals(order)) {

SearchHighestScore(data);

SearchLowestScore(data);

} else if ("2".equals(order)) {

OrderStudents(data);

} else if ("3".equals(order)) {

ScoreUnder60(data);

} else if ("4".equals(order)) {

String name;

System.out.println("请输入学生的姓名:");

Scanner s = new Scanner(System.in);

name = s.nextLine();

if (SearchScore(name) != null)

System.out.println(name + "的总分为:" + SearchScore(name));

else

System.out.println("查无此人");

} else if ("5".equals(order)) {

Test obj = new Test();

obj.end_flag = false;

System.out.println("退出");

} else {

System.out.println("输入有误!");

}

}

public void InputData() {

for (int i = 1; i = STUDENTS_NUM; i++) {

System.out.print("请输入第" + i + "个人的姓名" + ":");

Scanner s1 = new Scanner(System.in);

name = s1.nextLine();

data[i - 1][0] = name;

System.out.print("请输入第" + i + "个人的语文成绩" + ":");

Scanner s2 = new Scanner(System.in);

Chinese_score = s2.nextInt();

data[i - 1][1] = String.valueOf(Chinese_score);

System.out.print("请输入第" + i + "个人的数学成绩" + ":");

Scanner s3 = new Scanner(System.in);

Math_score = s3.nextInt();

data[i - 1][2] = String.valueOf(Math_score);

System.out.print("请输入第" + i + "个人的英语成绩" + ":");

Scanner s4 = new Scanner(System.in);

English_score = s4.nextInt();

data[i - 1][3] = String.valueOf(English_score);

data[i - 1][4] = String.valueOf(Chinese_score + Math_score

+ English_score);

System.out.println(data[i - 1][4]);

}

}

}

用JAVA的switch来编一个程序实现成绩的查询,有些问题

先判 范围 再 case 搞一方法

private int check(int a)

{

if (a90)

return 1;

else if(90=a a=80)

return 2;

.........

}

switch(check(a)){

case 1:

System.out.println("成绩优秀");

.......

}

}

求用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://cdweb.net/article/heshoc.html