學生成績管理系統java
㈠ 用java編寫一個學生成績管理系統. //1.學生類 學號 姓名 年齡 語數外三科成績(三科成績)
用數組可以,也可以用集合來存儲各個同學的成績。
添加刪除等信息簡單。
這里有個迷你圖書管理系統,類似,我剛寫的。你看看之後應該會有思路了。如果用集合utils做的話,也簡單,知識用到了集合框架和泛型等機制。
package cn.kgc.sg.MiTuSys;
import java.util.Scanner;
public class MiNiBookSys {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
// 定義書的信息
String[] bookNames = new String[4];
int[] borrowDate = new int[5];
int[] borrowCount = new int[4];
int[] states = new int[4];
// 定義書單信息
String[] bookMeg = new String[5];
bookMeg[0] = "Java開發";
bookMeg[1] = "C#開發";
bookMeg[2] = "C語言開發";
states[2] = 0; // 0:可借閱 1:已借出
// 初始化兩個圖書借閱記錄信息
bookNames[0] = "安徒生童話";
borrowDate[0] = 15;
borrowCount[0] = 4;
states[0] = 0; // 0:可借閱 1:已借出
bookNames[1] = "格林童話";
states[1] = 1; // 0:可借閱 1:已借出
borrowDate[1] = 26;
borrowCount[1] = 9;
// 搭建項目框架
int num = -1;// 定義用戶初始輸入的數字
do {
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.print("請輸入您的選擇:");
int choose = sc.nextInt();
// 判斷輸入的選擇是否正確
while (choose < 0 || choose > 6) {
System.out.print("輸入有誤,請重新輸入:");
choose = sc.nextInt();
}
// 定義一個flag變數,來定義是否退出系統
boolean flag = true;// true:不退出系統 false:退出系統
String addName = null;
switch (choose) {
case 1:
System.out.println(" *********1.新增圖書*********");
boolean isAdd = true;
System.out.println("序號 圖書書名");
for (int i = 0; i < bookMeg.length; i++) {
// 判斷為空的不輸出
if (bookMeg[i] != null) {
System.out.println((i + 1) + " " + bookMeg[i]);
}
}
System.out.print("請輸入新增圖書名稱:");
addName = sc.next();
for (int i = 0; i <bookMeg.length; i++) {
// 判斷為空的不輸出
if (bookMeg[i] == null) {
bookMeg[i] = addName;
break;
}
}
/*bookMeg[bookMeg.length-1] = addName; //添加圖書信息
*/ System.out.println(" 序號 圖書書名");
for (int i = 0; i < bookMeg.length; i++) {
// 判斷為空的不輸出
if (bookMeg[i] != null) {
System.out.println((i + 1) + " " + bookMeg[i]);
}
}
if (!isAdd) {
System.out.println("對不起,圖書已滿,不能添加!!!");
}
break;
case 2:
System.out.println(" *********2.查看圖書*********");
System.out.println("序號" + " 圖書書名" + " 借閱次數 借閱狀態 借閱日期 ");
// 遍歷數組
for (int i = 0; i < bookNames.length; i++) {
// 判斷信息為空的不輸出
if (bookNames[i] != null) {
String borrowCounts = borrowCount[i] + "次";
String borrowDates = borrowDate[i] + "日";
String state = (states[i] == 0) ? "可借閱" : "已借出";
System.out.println((i + 1) + " " + bookNames[i] + " " + borrowCounts + " " + state
+ " " + borrowDates);
}
}
break;
case 3:
System.out.println(" *********3.刪除圖書*********");
System.out.println("序號 圖書書名");
for (int i = 0; i < bookMeg.length; i++) {
// 判斷為空的不輸出
if (bookMeg[i] != null) {
System.out.println((i + 1) + " " + bookMeg[i]);
}
}
System.out.print("請輸入刪除的圖書序號:");
int delNo = sc.nextInt();
// 判斷輸入的序號是否有誤
while (delNo < 1 || delNo > bookMeg.length) {
System.out.print("輸入有誤,重新輸入:");
delNo = sc.nextInt();
}
// 刪除圖書
for (int i = 0; i <=bookMeg.length-1;i++) {
if (bookMeg[i] != null && i == delNo - 1) {
bookMeg[i] = bookMeg[i+1];
bookMeg[i+1] = null; //
// 最後置空
bookMeg[bookMeg.length - 1] = null;
}
}
for (int i = 0; i < bookMeg.length; i++) {
// 判斷為空的不輸出
if (bookMeg[i] != null) {
System.out.println((i + 1) + " " + bookMeg[i]);
}
}
break;
case 4:
System.out.println(" *********4.圖書借閱*********");
System.out.println(" 序號 圖書書名 借閱狀態 借閱次數 借閱日期");
for (int i = 0; i < bookMeg.length; i++) {
// 判斷為空的不輸出
if (bookMeg[i] != null) {
String state = (states[i] == 0) ? "可借閱" : "已借出";
String borrowCi = borrowCount[i] + "次";
System.out.println((i + 1) + " " + bookMeg[i] + " " + state + " " + borrowCi + " "
+ borrowDate[i]);
}
}
System.out.print("請輸入您要借閱的圖書序號:");
int borrowNo = sc.nextInt();
boolean isFind = true;// false:找不到
for (int i = 0; i < bookMeg.length; i++) {
// 查到了,但是狀態是0可借閱,可以借閱
if (i == borrowNo - 1 && states[i] == 0) {
isFind = true;
// 改變狀態為已借出
states[i] = 1;
// 借閱次數加一
borrowCount[i]++;
// 輸入借閱日期
System.out.print("請輸入借閱日期:");
int borrow = sc.nextInt();
// 對輸入的日期判斷
while (borrow < 1 || borrow > 31) {
System.out.print("您輸入日期有誤,請重新輸入:");
borrow = sc.nextInt();
}
// 更新借閱日期
borrowDate[i] = borrow;
} else if (i == borrowNo - 1 && states[i] == 1) {
// 查到了,但是狀態是1已借出,不可以借閱
isFind = true;
System.out.println("狀態是已借出,不可以借閱!!!");
}
}
if (!isFind) {
System.out.println("找不到圖書!");
break;
}
break;
case 5:
System.out.println(" *********5.歸還圖書*********");
System.out.println(" 序號 圖書書名 借閱狀態 借閱次數 借閱日期");
for (int i = 0; i < bookMeg.length; i++) {
// 判斷為空的不輸出
if (bookMeg[i] != null) {
String state = (states[i] == 0) ? "可借閱" : "已借出";
String borrowCi = borrowCount[i] + "次";
System.out.println((i + 1) + " " + bookMeg[i] + " " + state + " " + borrowCi + " "
+ borrowDate[i]);
}
}
System.out.print("請輸入您要歸還的圖書序號:");
int huanNo = sc.nextInt();
// 判斷歸還的序號是否合法
while (huanNo < 1 || huanNo > bookMeg.length - 1) {
System.out.print("輸入的歸還圖書序號有誤,請重新輸入:");
huanNo = sc.nextInt();
}
boolean isHuan = true;// false:找不到
for (int i = 0; i < bookMeg.length; i++) {
// 查到了,但是狀態是1已借出,可以還
if (i == huanNo - 1 && states[i] == 1) {
isHuan = true;
// 改變狀態為已借出
states[i] = 0;
// 輸入歸還日期
System.out.print("請輸入歸還日期:");
int huan = sc.nextInt();
// 對歸還的日期判斷,必須大於借閱日期
while (huan < 1 || huan > 31) {
System.out.print("您輸入日期有誤,請重新輸入(1-31):");
huan = sc.nextInt();
}
while (huan < borrowDate[i]) {
System.out.print("歸還日期必須大於借閱日期" + borrowDate[i] + "號,請重新輸入:");
huan = sc.nextInt();
}
borrowCount[i]++;
System.out.println("歸還圖書成功!!!");
} else if (i == huanNo - 1 && states[i] == 0) {
// 查到了,但是狀態是0可借閱,不能還
isFind = true;
System.out.println("狀態是可借閱,不可以歸還!!!");
}
}
if (!isHuan) {
System.out.println("抱歉,找不到圖書,不能歸還圖書!");
break;
}
break;
case 6:
System.out.println(" *********6.退出系統*********");
flag = false;
break;
default:
flag = false;
break;
}
if (flag) {
System.out.print("輸入0返回:");
num = sc.nextInt();
} else {
break;
}
} while (num == 0);
System.out.println("**********謝謝使用**********");
}
}
希望能幫到你!!!
㈡ java設計一個學生成績管理系統
public static void main(String[] args) throws IOException {
Scanner sc = new Scanner(System.in);
String exit="";
Map<String, List<Float>> map1=new HashMap();
while(!exit.equals("exit")) {
System.out.println("請出入學生姓名");
List<Float> list = new ArrayList<Float>();
map1.put(sc.next(), list);
for(int i=0;i<3;i++) {
System.out.println("請出入學生成績");
list.add(sc.nextFloat());
}
System.out.println("輸入 exit 退出成績錄入,其他則繼續錄入");
exit=sc.next();
}
for(String key :map1.keySet()) {
List<Float> list =map1.get(key);
float avage =0l;
for(Float box :list) {
avage += box;
}
System.out.println(key+"的平均成績:"+ avage/list.size());
}
}
//只做了第一題,追加分數,可得第二題答案
㈢ 如何用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做一個學生成績管理系統需要哪些技術
用java做一個學生成績管理系統,可以用到如下技術:
後台:SSH框架,不用框架的話,單純地用JSP + Servlet也可以。
前台:html + css + js + jquery
資料庫:掌握SQL語言的編寫,資料庫的連接。復雜的項目還需要用到存儲過程。
㈤ 求一個用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(); //創建一個對象 }