java成绩统计系统代码,基于java的学生成绩管理系统代码
用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编写的学生成绩管理系统的完整代码
package jdbcproj;
import java.sql.*;
import java.awt.BorderLayout;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.awt.event.ActionEvent;
public class MainFrame extends JFrame {
private JPanel contentPane;
private JTextField txtname;
private JTextField txtpassword;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
MainFrame frame = new MainFrame();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
*/
public MainFrame() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 661, 399);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
JLabel lblNewLabel = new JLabel("\u7528\u6237\u540D");
lblNewLabel.setBounds(114, 51, 72, 18);
contentPane.add(lblNewLabel);
JLabel lblNewLabel_1 = new JLabel("\u5BC6\u7801");
lblNewLabel_1.setBounds(114, 106, 72, 18);
contentPane.add(lblNewLabel_1);
txtname = new JTextField();
txtname.setBounds(261, 48, 86, 24);
contentPane.add(txtname);
txtname.setColumns(10);
txtpassword = new JTextField();
txtpassword.setBounds(261, 103, 86, 24);
contentPane.add(txtpassword);
txtpassword.setColumns(10);
JButton btnadd = new JButton("\u589E\u52A0");
btnadd.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if(txtname.getText().equals("")||txtpassword.getText().equals(""))
{
JOptionPane.showMessageDialog(getContentPane(), "用户名和密码不能为空","提示信息框",JOptionPane.WARNING_MESSAGE);
}
else{
Users u=new Users();
u.setPwd(txtpassword.getText());
u.setUsername(txtname.getText());
UserDAO usdo=new UserDAO();
usdo.addUser(u);
}
}
});
btnadd.setBounds(45, 205, 113, 27);
contentPane.add(btnadd);
JButton btndelete = new JButton("\u5220\u9664");
btndelete.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
if(txtname.getText().equals(""))
{
JOptionPane.showMessageDialog(getContentPane(), "用户名不能为空","提示信息框",JOptionPane.WARNING_MESSAGE);
}
else{
UserDAO usdo=new UserDAO();
usdo.delUser(txtname.getText());;
}
}
});
btndelete.setBounds(172, 205, 113, 27);
contentPane.add(btndelete);
JButton btnupdate = new JButton("\u4FEE\u6539");
btnupdate.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if(txtname.getText().equals("")||txtpassword.getText().equals(""))
{
JOptionPane.showMessageDialog(getContentPane(), "用户名和密码不能为空","提示信息框",JOptionPane.WARNING_MESSAGE);
}
else{
Users u=new Users();
u.setPwd(txtpassword.getText());
u.setUsername(txtname.getText());
UserDAO usdo=new UserDAO();
usdo.updateUser(u);;
}
}
});
btnupdate.setBounds(300, 205, 113, 27);
contentPane.add(btnupdate);
JButton btnfind = new JButton("\u67E5\u8BE2");
btnfind.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if(txtname.getText().equals(""))
{
JOptionPane.showMessageDialog(getContentPane(), "用户名不能为空","提示信息框",JOptionPane.WARNING_MESSAGE);
}
else{
Users u=new Users();
UserDAO usdo=new UserDAO();
u=usdo.findUser(txtname.getText(), txtpassword.getText());
if(u!=null){
JOptionPane.showMessageDialog(getContentPane(), "该用户存在!","提示信息框",JOptionPane.WARNING_MESSAGE);
}
else{
JOptionPane.showMessageDialog(getContentPane(), "该用户不存在!","提示信息框",JOptionPane.WARNING_MESSAGE);
}
}
}
});
btnfind.setBounds(427, 205, 113, 27);
contentPane.add(btnfind);
//记得要写这个
setVisible(true);
}
}
求用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代码问题!输入5名学生的成绩,并计算总成绩,平均分,最高分,最低分
public static void main(String[] args) {
double scores[] = new double[5];
double total = 0;
double avg = 0;
double max = 0;
double min = 0;
int count=0;
String inputStr=null;
System.out.println("请输入5名学生的成绩:");
Scanner input = new Scanner(System.in);
while(count5){
try{
if(count 5){
System.out.println("请输入第"+(count+1)+"个分数:");
}
inputStr=input.nextLine();
scores[count++]=Double.valueOf(inputStr.trim());
}catch(Exception e){
if(inputStr!=null "exit".equals(inputStr.trim())){
System.out.println("您已成功结束程序");
System.exit(0);
}
System.out.println("若想结束请输入:exit");
System.out.print("您输入的分数不是数值类型,");
count--;
}
}
input.close();
Arrays.sort(scores);
min=scores[0];
max=scores[scores.length-1];
for(double score :scores){
total += score;
}
avg=total/scores.length;
System.out.println("总成绩是" + total);
System.out.println("最高分是" + max);
System.out.println("最低分是" + min);
System.out.println("平均分是" + avg);
}
//-------------------------------------------------------------------------
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
while(true){
Double[] scores = null;
double total = 0;
double avg = 0;
double max = 0;
double min = 0;
int count=1;
ListDouble inputScores=new ArrayListDouble();
String inputStr=null;
System.out.println("请输入要统计学生的成绩(理论上可以输入无限个,前提是你有那么大的内存):");
while(true){
try{
System.out.println("请输入第"+count+++"个分数,或输入ok进行计算,离开请输入exit");
inputStr=input.nextLine();
inputScores.add((double)Double.valueOf(inputStr.trim()));
}catch(Exception e){
if(inputStr!=null "exit".equals(inputStr.trim().toLowerCase())){
System.out.println("您已成功结束程序");
input.close();
System.exit(0);
}
if(inputStr!=null "ok".equals(inputStr.trim().toLowerCase())){
break;
}
System.out.println("您输入的分数不是数值类型,");
System.out.println("若想结束请输入exit ,若想计算结果请输入ok");
count--;
}
}
if(inputScores.size()==0){
System.out.println("您没有输入学生成绩,无数据可统计,程序结束。");
return ;
}
scores=inputScores.toArray(new Double[inputScores.size()]);
Arrays.sort(scores);
min=scores[0];
max=scores[scores.length-1];
for(double score :scores){
total += score;
}
avg=total/scores.length;
System.out.println("总成绩是" + total);
System.out.println("最高分是" + max);
System.out.println("最低分是" + min);
System.out.println("平均分是" + avg);
}
}
分享标题:java成绩统计系统代码,基于java的学生成绩管理系统代码
URL链接:http://pwwzsj.com/article/hesidj.html