成都网站建设设计

将想法与焦点和您一起共享

java实现成绩查询代码 Java成绩查询

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

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

网站建设哪家好,找成都创新互联!专注于网页设计、网站建设、微信开发、微信小程序定制开发、集团企业网站建设等服务项目。为回馈新老客户创新互联还提供了晋州免费建站欢迎大家使用!

简单的Java程序,实现学生的数学,语文成绩的录入排序和查询。

我刚写的,可能还有点漏洞

import java.util.*;

import java.util.Scanner;

public class Bd05 {

public static final Scanner s = new Scanner(System.in);

public static void main(String[] args) {

ArrayListStudent al = new ArrayListStudent();

home(al);

}

public static void home(ListStudent list){

while(true){

System.out.println("1.录入学生信息     2.查询学生信息     3.删除学生信息     4.退出\n输入数字选择:");

int num = s.nextInt();

switch(num){

case 1:

inputInfo(list);

break;

case 2:

findInfo(list);

break;

case 3:

remove(list);

break;

case 4:

System.exit(0);

}

}

}

public static void findInfo(ListStudent list){ //查询信息

System.out.println("1.升序     2.降序      3.返回\n输入数字选择查询方式(两科的总分):");

int num = 0;

while(true){

num = s.nextInt();

if(num==1){ //升序

Collections.sort(list,new ComparatorStudent(){

public int compare(Student s1, Student s2) {

int n = new Integer(s1.getChinese()+s1.getMath()).compareTo(new Integer(s2.getChinese()+s2.getMath()));

if(n==0)

return s1.getName().compareTo(s2.getName());

return n;

}

});

printAll(list);

}

else if(num==2){ //降序

Collections.sort(list,new ComparatorStudent(){

public int compare(Student s1, Student s2) {

int n = new Integer(s2.getChinese()+s2.getMath()).compareTo(new Integer(s1.getChinese()+s1.getMath()));

if(n==0)

return s2.getName().compareTo(s1.getName());

return n;

}

});

printAll(list);

}

else if(num==3)

break;

else

System.out.println("输入错误,重新输入:");

}

home(list);

}

public static void remove(ListStudent list){ //删除信息

System.out.print("输入需要删除的姓名:");

String name = s.next();

IteratorStudent it = list.listIterator();

while(it.hasNext()){

Student str = it.next();

if(name.equals(str.getName())){

it.remove();

System.out.println(name+" 删除成功!");

}

}

System.out.println("1.继续     2.返回\n输入数字选择:");

while(true){

int num = s.nextInt();

if(num==1){

remove(list);

}

else if(num==2)

break;

else

System.out.println("输入错误,重新输入:");

}

home(list);

}

public static void printAll(ListStudent list){

int num = 1;

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

for(Student stu:list){

System.out.println(num++ +".姓名:"+stu.getName()+"|语文成绩:"+stu.getChinese()+"|数学成绩:"+stu.getMath()+"---|总分:"+(stu.getChinese()+stu.getMath()));

}

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

home(list);

}

public static void inputInfo(ListStudent list){ //输入信息

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

String name = s.next();

System.out.println("输入数学成绩:");

int Math = s.nextInt();

System.out.println("输入语文成绩:");

int chinese = s.nextInt();

list.add(new Student(name,Math,chinese));

System.out.println("1.返回     2.继续录入\n输入数字选择:");

while(true){

int num = s.nextInt();

if(num==1)

break;

else if(num==2)

inputInfo(list);

else

System.out.println("输入错误,重新输入:");

}

home(list);

}

}

class Student{

private String name;

private int chinese;

private int math;

Student(String name,int math,int chinese){

this.name = name;

this.chinese = chinese;

this.math = math;

}

public String  getName(){

return name;

}

public int getChinese(){

return chinese;

}

public int getMath(){

return math;

}

}

Java编程题,模拟成绩查询

import java.util.HashMap;

import java.util.LinkedList;

import java.util.Map;

import java.util.Scanner;

public class Test {

LinkedListHashMapString, Integer examList;

public Test() {

LinkedListHashMapString, Integer examList = new LinkedListHashMapString,Integer();

//第一次

HashMapString, Integer first = new HashMapString, Integer();

first.put("张三", 80);

first.put("李四", 65);

first.put("王五", 35);

first.put("薛六", 90);

first.put("赵七", 70);

//第二次

HashMapString, Integer second = new HashMapString, Integer();

second.put("张三", 88);

second.put("李四", 75);

second.put("王五", 45);

second.put("薛六", 92);

second.put("赵七", 75);

//第三次

HashMapString, Integer third = new HashMapString, Integer();

third.put("张三", 86);

third.put("李四", 67);

third.put("王五", 55);

third.put("薛六", 98);

third.put("赵七", 65);

//第四次

HashMapString, Integer fourth = new HashMapString, Integer();

fourth.put("张三", 88);

fourth.put("李四", 80);

fourth.put("王五", 59);

fourth.put("薛六", 88);

fourth.put("赵七", 68);

examList.add(first);

examList.add(second);

examList.add(third);

examList.add(fourth);

this.examList = examList;

}

//通过次数获得总成绩

public int getExamCount(int times) {

int count = 0;

HashMapString, Integer  exam = examList.get(times-1); 

for(String studentName :exam.keySet()) {

int score = exam.get(studentName);

count += score;

return count;

}

//通过学生姓名获得学生总成绩

public int getStudentExamCount(String name) {

int count = 0;

for(HashMapString, Integer  exam  : examList) {

int score = exam.get(name);

count += score;

}

return count;

}

//通过学生姓名获得学生的平局成绩

public int getStudentExamAvg(String name) {

int count = 0;

int times = 0;

for(HashMapString, Integer  exam  : examList) {

times++;

int score = exam.get(name);

count += score;

}

return count/times;

}

//查询全班平均分最高的一次

public MapInteger,Integer getClassMaxAvg() {

MapInteger,Integer result = new HashMapInteger,Integer();

int time = 0;//存储考试次数

int maxScoreAvg=0;//存储最高的考试成绩

int i = 0;//当前考试次数

for(HashMapString, Integer  exam  : examList) {

i++;

int scoreCount = 0;//存储考试成绩总和

for(String name : exam.keySet()) {

int score = exam.get(name);

scoreCount += score;

}

if((scoreCount/4) maxScoreAvg) {

time = i;

maxScoreAvg = scoreCount/4;

}

}

result.put(time, maxScoreAvg);

return result;

}

//通过学生姓名和考试次数获得学生的某次考试成绩

public int getStudentExam(String name,int times) {

MapString,Integer exam = examList.get(times-1);

int score = exam.get(name);

return score;

}

public void showTitle() {

System.out.println("==========成绩查询说明==========");

System.out.println("输入 1@[考试次数] 查询某次考试总成绩  如 1@2");

System.out.println("输入 2@[学生姓名] 查询某考生总成绩  如 2@李四");

System.out.println("输入 3@[学生姓名] 查询某考生平均成绩  如 3@李四");

System.out.println("输入 4 查询全班平均分最高的次数和成绩  如 4");

System.out.println("输入 5@[学生姓名]@[考试次数] 查询某考生某次成绩  如 5@张三@2");

System.out.println("==========成绩查询说明==========");

}

public static void main(String[] args) {

Test test = new Test();

test.showTitle();

Scanner s = new Scanner(System.in);

String input;

while(s.hasNext()) {

try {

input = s.next();

if(input.startsWith("1")) {

String[] inputs = input.split("@");

System.out.println("第"+inputs[1]+"次总成绩为:"+test.getExamCount(Integer.valueOf(inputs[1])));

}else if(input.startsWith("2")) {

String[] inputs = input.split("@");

System.out.println(inputs[1]+"的总成绩为:"+test.getStudentExamCount(inputs[1]));

}else if(input.startsWith("3")) {

String[] inputs = input.split("@");

System.out.println(inputs[1]+"平均成绩为:"+test.getStudentExamAvg(inputs[1]));

}else if(input.startsWith("4")) {

System.out.println("全班平均分最高的次数和成绩为:"+test.getClassMaxAvg());

}else if(input.startsWith("5")) {

String[] inputs = input.split("@");

System.out.println(inputs[1]+"第"+inputs[2]+"次考试成绩为:"+test.getStudentExam(inputs[1],Integer.valueOf(inputs[2])));

}else {

test.showTitle();

}

}catch(Exception e) {

test.showTitle();

}

}

}

}

用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实现数据库的链接查询学生成绩! 求代码

可使用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.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成绩查询
文章起源:http://chengdu.cdxwcx.cn/article/hhihid.html