java使用數組編寫學生成績管理系統
㈠ 如何用Java語言編寫學生成績管理系統
寫過一個類似的給了你吧
packagestudent;
importjava.util.Scanner;
publicclassteststudent{
publicstaticvoidmain(Stringargs[]){
System.out.println("************************學生成績管理系統*********************");
System.out.println("請輸入要管理的學生人數:");
Scannersc=newScanner(System.in);
intn=sc.nextInt();
studentMassagestum=newstudentMassage(n);
intflag=1;
while(flag==1){
System.out.println("1.輸入學生信息");
System.out.println("2.通過姓名查找學生信息");
System.out.println("3.顯示全部學生信息");
System.out.println("4.退出系統");
intop=sc.nextInt();
switch(op){
case1:stum.addStudent(n);
newScanner(System.in).nextLine();
break;
case2:
System.out.println("輸入學生姓名:");
Stringname=sc.next();
stum.FindStudent(name);
newScanner(System.in).nextLine();
break;
case3:
stum.showallStudent();
newScanner(System.in).nextLine();
break;
case4:
flag=0;
System.out.println("已退出系統!");
break;
default:
System.out.println("輸入有誤!");
newScanner(System.in).nextLine();
}
}
}
}
classDate{
intyear;
intmonth;
intday;
/*publicDate(intyear,intmonth,intday){
this.year=year;
this.month=month;
this.day=day;
}
publicDate(){}*/
publicStringshowDate(){
returnyear+"/"+month+"/"+day;
}
}
classstudent{
intid;
Stringname;
Datedate;
floatscore;
publicstudent(){
id=0;
name=null;
date=null;
score=0f;
}
publicvoidshowStudent(){
System.out.println(id+""+name+""+""+date.showDate()+""+score);
}
}
classstudentMassage{
privatestudent[]stu;
privateintflag;
publicstudentMassage(intn){
flag=0;
if(stu==null){
stu=newstudent[n];
for(inti=0;i<n;++i){
stu[i]=newstudent();
}
}
}
publicvoidaddStudent(intn){
flag=1;
Scannersc=newScanner(System.in);
System.out.println("請輸入"+n+"個學生信息");
for(inti=0;i<stu.length;++i){
stu[i].date=newDate();
System.out.println("請輸入第"+(i+1)+"個學生學號:");
stu[i].id=sc.nextInt();
System.out.println("請輸入第"+(i+1)+"個學生姓名:");
stu[i].name=sc.next();
System.out.println("請輸入第"+(i+1)+"個學生出生年份:");
stu[i].date.year=sc.nextInt();
System.out.println("請輸入第"+(i+1)+"個學生出生月份:");
stu[i].date.month=sc.nextInt();
System.out.println("請輸入第"+(i+1)+"個學生出生日期:");
stu[i].date.day=sc.nextInt();
//stu[i].date=newDate(year,month,day);
System.out.println("請輸入第"+(i+1)+"個學生分數:");
stu[i].score=sc.nextFloat();
}
}
publicvoidFindStudent(Stringsname){
studentfind=null;
if(flag!=0){
for(inti=0;i<stu.length;++i){
if(sname.equals(stu[i].name))
find=stu[i];
}
if(find==null)
System.out.println("查無此人!");
else
find.showStudent();
}else
System.out.println("沒有輸入學生信息!");
}
publicvoidshowallStudent(){
System.out.println("所有學生的信息如下:");
System.out.println("學號姓名生日分數");
for(inti=0;i<stu.length;++i){
stu[i].showStudent();
}
}
}
㈡ 速求Java學生成績管理系統 用數組 不要用資料庫
public class Test04
{
public static List<Students> list = new ArrayList<Students>();
public static void main(String[] args)
{
Scanner scan = new Scanner(System.in);
int t;
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("7.退出");
System.out.println("請輸入你的操作(1-7):");
String s = scan.nextLine();
if (null==s||"".equals(s))
{
continue;
}else {
t = Integer.parseInt(s);
}
if (0==t)
{
break;
}
}
}
}
class Students{
int id;
String name;
}
後面可以自己做判斷,寫方法實現
㈢ 利用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(); //創建一個對象 }
㈤ 如何用java來編一個學生成績管理系統的程序
同意上面的說復法..
你需要一制個IO包.實例化輸入輸出流.對文件進行輸入輸出的操作.
你先把這些類文件都寫好.這些類文件都很簡單.寫一個實例,省去一些代碼..
public class Person
{
public string studentName;
public string studentAge;
//省略其它成員變數
public void setStudentName(string strName)
{
this.studentName=strName;
}
public string getStudentName()
{
return this.studentName;
}
//其它成員函數類似
}
上面一個類的實例..其他類差不多,然後寫一個類.實例化這些類,用文件IO輸入輸出流,對文件進行操作.這里代碼你自己去寫,不會網上多的是.
㈥ 如何用Java語言編寫學生成績管理系統
package student;
import java.util.Scanner;
public class teststudent {
public static void main(String args[]){
System.out.println("************************學生成績管理系統*********************");
System.out.println("請輸入要管理的學生人數:");
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
studentMassage stum = new studentMassage(n);
int flag = 1;
while(flag == 1){
System.out.println("1.輸入學生信息");
System.out.println("2.通過姓名查找學生信息");
System.out.println("3.顯示全部學生信息");
System.out.println("4.退出系統");
int op = sc.nextInt();
switch(op){
case 1:stum.addStudent(n);
new Scanner(System.in).nextLine();
break;
case 2:
System.out.println("輸入學生姓名:");
String name = sc.next();
stum.FindStudent(name);
new Scanner(System.in).nextLine();
break;
case 3:
stum.showallStudent();
new Scanner(System.in).nextLine();
break;
case 4:
flag = 0;
System.out.println("已退出系統!");
break;
default:
System.out.println("輸入有誤!");
new Scanner(System.in).nextLine();
}
}
}
}
class Date{
int year;
int month;
int day;
/*public Date(int year,int month,int day){
this.year = year;
this.month = month;
this.day = day;
}
public Date(){}*/
public String showDate(){
return year + "/"+ month+"/"+day;
}
}
class student{
int id;
String name;
Date date;
float score;
public student(){
id = 0;
name = null;
date = null;
score = 0f;
}
public void showStudent(){
System.out.println( id + " " + name + " "+ " " + date.showDate()+" "+score);
}
}
class studentMassage{
private student[] stu;
private int flag;
public studentMassage(int n){
flag = 0;
if(stu == null){
stu = new student[n];
for(int i =0;i<n;++i){
stu[i] = new student();
}
}
}
public void addStudent(int n){
flag = 1;
Scanner sc = new Scanner(System.in);
System.out.println("請輸入"+n+"個學生信息");
for(int i = 0 ;i<stu.length;++i){
stu[i].date = new Date();
System.out.println("請輸入第"+(i+1)+"個學生學號:");
stu[i].id = sc.nextInt();
System.out.println("請輸入第"+(i+1)+"個學生姓名:");
stu[i].name = sc.next();
System.out.println("請輸入第"+(i+1)+"個學生出生年份:");
stu[i].date.year = sc.nextInt();
System.out.println("請輸入第"+(i+1)+"個學生出生月份:");
stu[i].date.month = sc.nextInt();
System.out.println("請輸入第"+(i+1)+"個學生出生日期:");
stu[i].date.day = sc.nextInt();
//stu[i].date = new Date(year,month,day);
System.out.println("請輸入第"+(i+1)+"個學生分數:");
stu[i].score = sc.nextFloat();
}
}
public void FindStudent(String sname){
student find = null;
if(flag != 0){
for(int i = 0;i<stu.length;++i){
if(sname.equals(stu[i].name))
find = stu[i];
}
if(find == null)
System.out.println("查無此人!");
else
find.showStudent();
}else
System.out.println("沒有輸入學生信息!");
}
public void showallStudent(){
System.out.println("所有學生的信息如下:");
System.out.println("學號 姓名 生日 分數");
for(int i = 0;i<stu.length;++i){
stu[i].showStudent();
}
}
}
㈦ 用java編寫學生管理系統
我也是初學寫的不好
public class Student {
static int[] gradesArray={87,68,94,100,83,78,85,91,76,87};
public Student(int[]gradesArray){
}
public void printAllGrade(){
for (int i = 0; i < gradesArray.length; i++) {
System.out.println("學號"+(i+1)+"成績是"+gradesArray[i]);
}
}
public void printAvarage(){
double sum = 0;
for (int i = 0; i < gradesArray.length; i++) {
sum+=gradesArray[i];
}
System.out.println("\n平均成績是"+sum/gradesArray.length);
}
public void printMax(){
int max=gradesArray[0];
for (int i = 0; i < gradesArray.length; i++) {
if(gradesArray[i]>max){
max=gradesArray[i];
}
}
System.out.println("\n最高分時"+max);
}
public void printMin(){
int min=gradesArray[0];
for (int i = 0; i < gradesArray.length; i++) {
if (gradesArray[i]<min){
min=gradesArray[i];
}
}
System.out.println("\n最低分時"+min);
}
public void printDistribution(){
int a=0,b=0,c=0,d=0,e=0,f=0,g=0,h=0,j=0,k=0;
for (int i = 0; i < gradesArray.length; i++) {
if(gradesArray[i]<10){
a++;
}else if (gradesArray[i]>=10&&gradesArray[i]<20) {
b++;
}
else if (gradesArray[i]>=20&&gradesArray[i]<30) {
c++;
}
else if (gradesArray[i]>=30&&gradesArray[i]<40) {
d++;
}
else if (gradesArray[i]>=40&&gradesArray[i]<50) {
e++;
}
else if (gradesArray[i]>=50&&gradesArray[i]<60) {
f++;
}
else if (gradesArray[i]>=60&&gradesArray[i]<70) {
g++;
}
else if (gradesArray[i]>=70&&gradesArray[i]<80) {
h++;
}
else if (gradesArray[i]>=80&&gradesArray[i]<90) {
j++;
}
else if (gradesArray[i]>=90&&gradesArray[i]<100) {
k++;
}
}
System.out.println("\n成績分布是");
System.out.print("0-10:");
for (int i = 0; i <=a; i++) {
System.out.print("*");
}
System.out.print("10-20:");
for (int i = 0; i <=b; i++) {
System.out.print("*");
}
System.out.print("20-30:");
for (int i = 0; i <=c; i++) {
System.out.print("*");
}
System.out.print("30-40:");
for (int i = 0; i <=d; i++) {
System.out.print("*");
}
System.out.print("40-50:");
for (int i = 0; i <=e; i++) {
System.out.print("*");
}
System.out.print("50-60:");
for (int i = 0; i <=f; i++) {
System.out.print("*");
}
System.out.print("60-70:");
for (int i = 0; i <=g; i++) {
System.out.print("*");
}
System.out.print("70-80:");
for (int i = 0; i <=h; i++) {
System.out.print("*");
}
System.out.print("80-90:");
for (int i = 0; i <=j;i++) {
System.out.print("*");
}
System.out.print("90-100:");
for (int i = 0; i <=k; i++) {
System.out.print("*");
}
}
public static void main(String[] args) {
Student student=new Student(gradesArray);
student.printAllGrade();
student.printAvarage();
student.printMax();
student.printMin();
student.printDistribution();
}
}
㈧ 求用Java編寫的學生成績管理系統的完整代碼
packagejdbcproj;
importjava.sql.*;
importjava.awt.BorderLayout;
importjava.awt.EventQueue;
importjavax.swing.JFrame;
importjavax.swing.JPanel;
importjavax.swing.border.EmptyBorder;
importjavax.swing.JLabel;
importjavax.swing.JOptionPane;
importjavax.swing.JTextField;
importjavax.swing.JButton;
importjava.awt.event.ActionListener;
importjava.sql.Connection;
importjava.sql.PreparedStatement;
importjava.sql.SQLException;
importjava.awt.event.ActionEvent;
{
privateJPanelcontentPane;
privateJTextFieldtxtname;
privateJTextFieldtxtpassword;
/**
*Launchtheapplication.
*/
publicstaticvoidmain(String[]args){
.invokeLater(newRunnable(){
publicvoidrun(){
try{
MainFrameframe=newMainFrame();
frame.setVisible(true);
}catch(Exceptione){
e.printStackTrace();
}
}
});
}
/**
*Createtheframe.
*/
publicMainFrame(){
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100,100,661,399);
contentPane=newJPanel();
contentPane.setBorder(newEmptyBorder(5,5,5,5));
setContentPane(contentPane);
contentPane.setLayout(null);
JLabellblNewLabel=newJLabel("u7528u6237u540D");
lblNewLabel.setBounds(114,51,72,18);
contentPane.add(lblNewLabel);
JLabellblNewLabel_1=newJLabel("u5BC6u7801");
lblNewLabel_1.setBounds(114,106,72,18);
contentPane.add(lblNewLabel_1);
txtname=newJTextField();
txtname.setBounds(261,48,86,24);
contentPane.add(txtname);
txtname.setColumns(10);
txtpassword=newJTextField();
txtpassword.setBounds(261,103,86,24);
contentPane.add(txtpassword);
txtpassword.setColumns(10);
JButtonbtnadd=newJButton("u589Eu52A0");
btnadd.addActionListener(newActionListener(){
publicvoidactionPerformed(ActionEvente){
if(txtname.getText().equals("")||txtpassword.getText().equals(""))
{
JOptionPane.showMessageDialog(getContentPane(),"用戶名和密碼不能為空","提示信息框",JOptionPane.WARNING_MESSAGE);
}
else{
Usersu=newUsers();
u.setPwd(txtpassword.getText());
u.setUsername(txtname.getText());
UserDAOusdo=newUserDAO();
usdo.addUser(u);
}
}
});
btnadd.setBounds(45,205,113,27);
contentPane.add(btnadd);
JButtonbtndelete=newJButton("u5220u9664");
btndelete.addActionListener(newActionListener(){
publicvoidactionPerformed(ActionEventarg0){
if(txtname.getText().equals(""))
{
JOptionPane.showMessageDialog(getContentPane(),"用戶名不能為空","提示信息框",JOptionPane.WARNING_MESSAGE);
}
else{
UserDAOusdo=newUserDAO();
usdo.delUser(txtname.getText());;
}
}
});
btndelete.setBounds(172,205,113,27);
contentPane.add(btndelete);
JButtonbtnupdate=newJButton("u4FEEu6539");
btnupdate.addActionListener(newActionListener(){
publicvoidactionPerformed(ActionEvente){
if(txtname.getText().equals("")||txtpassword.getText().equals(""))
{
JOptionPane.showMessageDialog(getContentPane(),"用戶名和密碼不能為空","提示信息框",JOptionPane.WARNING_MESSAGE);
}
else{
Usersu=newUsers();
u.setPwd(txtpassword.getText());
u.setUsername(txtname.getText());
UserDAOusdo=newUserDAO();
usdo.updateUser(u);;
}
}
});
btnupdate.setBounds(300,205,113,27);
contentPane.add(btnupdate);
JButtonbtnfind=newJButton("u67E5u8BE2");
btnfind.addActionListener(newActionListener(){
publicvoidactionPerformed(ActionEvente){
if(txtname.getText().equals(""))
{
JOptionPane.showMessageDialog(getContentPane(),"用戶名不能為空","提示信息框",JOptionPane.WARNING_MESSAGE);
}
else{
Usersu=newUsers();
UserDAOusdo=newUserDAO();
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.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Admin {
public static void main(String[] args) throws IOException, ClassNotFoundException {
Scanner in = new Scanner(System.in);
int studentNum = 5;
List<Student> result = new ArrayList<Student>();
for (int i = 0; i < studentNum; i++) {
Student bean = new Student();
System.out.print("輸入第" + (i + 1) + "個學生學號:");
bean.setNo(in.next());
System.out.print("輸入第" + (i + 1) + "個學生姓名:");
bean.setName(in.next());
System.out.print("輸入第" + (i + 1) + "個學生數學成績:");
bean.setShuxue(in.nextDouble());
System.out.print("輸入第" + (i + 1) + "個學生語文成績:");
bean.setYuwen(in.nextDouble());
result.add(bean);
}
while (true) {
System.out.println("1.保存到文件;2.總成績;3.平均成績;4.不及格比例;5.及格比例;6,優良比例;0.退出.");
int i = in.nextInt();
if (i == 0) {
System.exit(0);
}
if (i == 1) {
save(result);
}
if (i == 2) {
for (int j = 0; j < result.size(); j++) {
Student s = result.get(j);
System.out.println("學生" + s.getName() + "的總成績是:" + s.all());
}
}
if (i == 3) {
int jigeSum = 0;
for (int j = 0; j < result.size(); j++) {
Student s = result.get(j);
if (!s.isJige()) {
jigeSum++;
}
}
System.out.println("不及格比例:" + jigeSum + "/" + result.size());
}
if (i == 4) {
// 篇幅受限,自行開發
}
if (i == 5) {
// 篇幅受限,自行開發
}
}
}
private static void save(List result) throws IOException {
FileOutputStream fs = new FileOutputStream("d:/a.txt");
ObjectOutputStream os = new ObjectOutputStream(fs);
os.writeObject(result);
os.flush();
os.close();
fs.close();
}
}
class Student implements Serializable {
private String no;
private String name;
private double shuxue;
private double yuwen;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getNo() {
return no;
}
public void setNo(String no) {
this.no = no;
}
public double getShuxue() {
return shuxue;
}
public void setShuxue(double shuxue) {
this.shuxue = shuxue;
}
public double getYuwen() {
return yuwen;
}
public void setYuwen(double yuwen) {
this.yuwen = yuwen;
}
public double all() {
return shuxue + yuwen;
}
public double avg() {
return all() / 2;
}
public boolean isJige() {
return avg() > 60;
}
}