學生管理系統java
Ⅰ java實現學生簡易信息管理系統
importjava.util.*;
importjava.io.*;
classStuMgr{
publicstaticclassStudent{
publicintid;
publicStringname;
publicintage;
publicStudent(intid,Stringname,intage){
this.id=id;
this.name=name;
this.age=age;
}
@Override
publicStringtoString(){
returnid+","+name+","+age;
}
}
publicList<Student>stuList=newLinkedList<>();
publicvoidadd(){
Scannersc=newScanner(System.in);
System.out.println("請輸入學生學號:");
Stringid=sc.nextLine();
intintId=0;
try{
intId=Integer.parseInt(id);
}catch(NumberFormatExceptionex){
System.out.println("學號輸入有誤,請輸入數字!");
return;
}
if(find(intId)!=null){
System.out.println("該學號已經存在!");
return;
}
System.out.println("請輸入學生姓名:");
Stringname=sc.nextLine();
System.out.println("請輸入學生年齡:");
Stringage=sc.nextLine();
intintAge=0;
try{
intAge=Integer.parseInt(age);
}catch(NumberFormatExceptionex){
System.out.println("年齡輸入有誤,請輸入數字!");
return;
}
Studentstu=newStudent(intId,name,intAge);
stuList.add(stu);
store();
System.out.println("-----------------------");
System.out.println("學生信息已增加");
System.out.println(stu);
System.out.println("-----------------------");
}
publicvoiddel(){
Scannersc=newScanner(System.in);
System.out.println("請輸入學生學號:");
Stringid=sc.nextLine();
intintId=0;
try{
intId=Integer.parseInt(id);
}catch(NumberFormatExceptionex){
System.out.println("學號輸入有誤,請輸入數字!");
return;
}
Studentstu=find(intId);
if(stu==null){
System.out.println("該學號不存在!");
return;
}
stuList.remove(stu);
store();
System.out.println("-----------------------");
System.out.println("學生信息已刪除");
System.out.println(stu);
System.out.println("-----------------------");
}
publicvoidfind(){
Scannersc=newScanner(System.in);
System.out.println("請輸入學生學號:");
Stringid=sc.nextLine();
intintId=0;
try{
intId=Integer.parseInt(id);
}catch(NumberFormatExceptionex){
System.out.println("學號輸入有誤,請輸入數字!");
return;
}
Studentstu=find(intId);
if(stu==null){
System.out.println("該學號不存在!");
return;
}
System.out.println("-----------------------");
System.out.println("查找學生信息如下");
System.out.println(stu);
System.out.println("-----------------------");
}
publicStudentfind(intid){
for(Studentstu:stuList){
if(stu.id==id){
returnstu;
}
}
returnnull;
}
publicvoidmodify(){
store();
}
publicvoidforeach(){
System.out.println("-----------------------");
for(Studentstu:stuList){
System.out.println(stu);
}
System.out.println("-----------------------");
}
publicvoidstore(){
Iteratoriterator=stuList.iterator();
Filefile=newFile("stuList.txt");
FileWriterfw=null;
BufferedWriterwriter=null;
try{
fw=newFileWriter(file);
writer=newBufferedWriter(fw);
while(iterator.hasNext()){
writer.write(iterator.next().toString());
writer.newLine();//換行
}
writer.flush();
}catch(FileNotFoundExceptione){
e.printStackTrace();
}catch(IOExceptione){
e.printStackTrace();
}finally{
try{
writer.close();
fw.close();
}catch(IOExceptione){
e.printStackTrace();
}
}
}
publicstaticvoidmain(String[]args){
StuMgrmgr=newStuMgr();
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("-----------------------");
Scannersc=newScanner(System.in);
Stringop=sc.nextLine();
if("6".equals(op)){
return;
}
if("1".equals(op)){
mgr.add();
}
if("2".equals(op)){
mgr.del();
}
if("3".equals(op)){
mgr.find();
}
if("4".equals(op)){
mgr.modify();
}
if("5".equals(op)){
mgr.foreach();
}
}
}
}
時間倉促,還有一個modify方法沒實現,留給你自己練手。
Ⅱ 用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實現學生管理系統
這個java的學生管理熊天剛, 你需要的是基於gui界面的還是javaweb的呢?
這兩種項目有共性也有區別, 比如在數據層的部分可以統一的抽象出來公用。
但是在view層差別還蠻大的, swing是各種基於listener來觸發業務邏輯, 與javaweb開發不太一樣, 我最近兩種都有實現, 感受是還算簡單。
希望能夠幫助你
Ⅳ 如何用java寫一個學生管理系統
直接上開源網站上面找,http://www.oschina.net/code/snippet_141356_7590 這個有
Ⅳ java學生管理系統
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.lang.*;
public class Students extends Applet implements ActionListener
{
Vector StuInf=new Vector();
StudentInf SI;
String xm;
String bj;
int i,j,xh,cj;
static int mid;
Label prompt1=new Label("學生成績管理系統");
Label prompt2=new Label(" 用戶:");
Label prompt3=new Label(" 密碼:");
Label prompt4=new Label(" 班級:");
Label prompt5=new Label(" 成績:");
TextField input1=new TextField(8);
TextField input2=new TextField(8);
TextField input3=new TextField(8);
TextField input4=new TextField(8);
Button btn1=new Button("登錄");
Button btn2=new Button("增加");
Button btn3=new Button("修改");
Button btn4=new Button("刪除");
public void init()
{
setLayout(new GridLayout(6,3));
add(new Label());
add(prompt1);
add(new Label());
add(prompt2);
add(input1);
add(new Label());
add(prompt3);
add(input2);
add(btn1);
add(prompt4);
add(input3);
add(new Label());
add(prompt5);
add(input4);
add(new Label());
add(btn2);
add(btn3);
add(btn4);
prompt4.setVisible(false);
prompt5.setVisible(false);
input3.setVisible(false);
input4.setVisible(false);
btn2.setVisible(false);
btn3.setVisible(false);
btn4.setVisible(false);
btn1.addActionListener(this);
btn2.addActionListener(this);
btn3.addActionListener(this);
btn4.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
if(e.getActionCommand()=="登錄")
{
String a,b;
a=input1.getText();
b=input2.getText();
input1.setText("");
if((a.equals("12")==true)&&(b.equals("12")==true))
{
prompt2.setText(" 姓名:");
prompt3.setText(" 學號:");
prompt4.setVisible(true);
prompt5.setVisible(true);
input3.setVisible(true);
input4.setVisible(true);
btn2.setVisible(true);
btn3.setVisible(true);
btn4.setVisible(true);
btn3.setEnabled(false);
btn4.setEnabled(false);
btn1.setLabel("查詢");
input1.setText("登錄成功");
input1.selectAll();
}
else
input2.setText("用戶名或密碼錯");
}
if(e.getActionCommand()=="增加")
{
boolean scucss=true;
try
{
XingMing();
}
catch(EmptyException as)
{
input1.setText("姓名不能為空");
scucss=false;
}
try
{
xh=Integer.parseInt(input2.getText());
}
catch(NumberFormatException m)
{
input2.setText("學號為空或格式錯");
scucss=false;
}
bj=input3.getText();
try
{
ChengJi();
}
catch(EmptyException as)
{
cj=-1;
}
catch(OverException dd)
{
input4.setText("應在0-100間");
scucss=false;
}
catch(NumberFormatException cm)
{
input4.setText("成績應為數據");
scucss=false;
}
if(scucss==true)
{
SI=new StudentInf(xm,xh,bj,cj);
Insert(SI);
}
}
if(e.getActionCommand()=="修改")
{
xm=input1.getText();
xh=Integer.parseInt(input2.getText());
bj=input3.getText();
cj=Integer.parseInt(input4.getText());
SI=new StudentInf(xm,xh,bj,cj);
StuInf.setElementAt(SI, mid);
btn3.setEnabled(false);
}
if(e.getActionCommand()=="刪除")
{
StuInf.removeElementAt(mid);
btn4.setEnabled(false);
input1.setText("刪除成功");
input2.setText("");
input3.setText("");
input4.setText("");
}
if(e.getActionCommand()=="查詢")
{
boolean right=true;
try
{
xh=Integer.parseInt(input2.getText());
}
catch(NumberFormatException m)
{
input2.setText("學號為空或格式錯");
right=false;
}
if(right==true)
{
search(xh);
btn3.setEnabled(true);
btn4.setEnabled(true);
}
}
}
//查找方法
public void search(int k)
{
boolean exist=false;
int low=0;
int high=StuInf.size()-1;
while(low<=high)
{
mid=(high+low)/2;
StudentInf a1=(StudentInf) StuInf.elementAt(mid);
if(a1.getStuNo()==k)
{
SI=(StudentInf) StuInf.elementAt(mid);
String x = String.valueOf(SI.getStuNo());
exist=true;
input1.setText(SI.getname());
input1.selectAll();
input2.setText("0"+x);
input3.setText(SI.getClassNo());
if(SI.getLevel()==-1)
input4.setText("未參加考試");
else
{
String y = String.valueOf(SI.getLevel());
input4.setText(y);
}
break;
}
else if(a1.getStuNo()<k)
low=mid+1;
else
high=mid-1;
}
if(exist==false)
{
input1.setText("無此學號學生信息");
input1.selectAll();
}
}
//添加方法
public void Insert(StudentInf q)
{
int i=0;
if(StuInf.isEmpty()==true)
{
StuInf.addElement(q);
input1.setText("");
input2.setText("");
input3.setText("");
input4.setText("");
}
else
{
StudentInf xh;
xh=(StudentInf) StuInf.firstElement();
while(xh.getStuNo()<q.getStuNo())
{
i++;
if(i<StuInf.size())
xh=(StudentInf) StuInf.elementAt(i);
else
break;
}
if(xh.getStuNo()==q.getStuNo())
{
input2.setText("此學生信息已存在");
input2.requestFocus();
input2.selectAll();
}
else
{
StuInf.insertElementAt(q,i);
input1.setText("");
input2.setText("");
input3.setText("");
input4.setText("");
}
}
}
//異常類
class OverException extends Exception
{
String over;
}
class EmptyException extends Exception
{
String empty;
}
void XingMing() throws EmptyException
{
if((input1.getText()).equals(""))
throw (new EmptyException());
else
xm=input1.getText();
}
void ChengJi() throws OverException,EmptyException
{
if((input4.getText()).equals(""))
throw(new EmptyException());
else
cj=Integer.parseInt(input4.getText());
if(cj<0||cj>100)
throw (new OverException());
}
//學生信息類
public class StudentInf
{
private String name;
private int StuNo;
private String ClassNo;
private int Level;
StudentInf(String xingming,int xuehao,String banji,int chengji)
{
name=xingming;
StuNo=xuehao;
ClassNo=banji;
Level=chengji;
}
public int getStuNo()
{
return StuNo;
}
public String getname()
{
return name;
}
public String getClassNo()
{
return ClassNo;
}
public int getLevel()
{
return Level;
}
}
}
Ⅵ Java實現一個簡單的學生信息管理系統
看了你的需求,其實除了java,你還可以用易查分來做查詢管理系統呢!通過易查分 不用寫代碼,上 傳個excel表格就可以生成,超級簡單的!
Ⅶ 簡單的JAVA學生管理系統代碼···
lList<Student> students = new ArrayList<Student>();
BufferedReader br = new BufferedReader(new FileReader("D:\student.txt"));
String tmpStr = br.readLine();
while(tmpStr != null){
int firstIndex = tmpStr.indexOf(" ");
int secondIndex = tmpStr.indexOf(" ",firstIndex + 1);
int thirdIndex = tmpStr.indexOf(" ", secondIndex + 1);
int forthIndex = tmpStr.indexOf(" ", thirdIndex + 1);
Integer stuId = Integer.parseInt(tmpStr.substring(0,firstIndex));
String stuName = tmpStr.substring(firstIndex + 1,secondIndex);
Integer stuYW = Integer.parseInt(tmpStr.substring(secondIndex + 1,thirdIndex));
Integer stuSX = Integer.parseInt(tmpStr.substring(thirdIndex + 1,forthIndex));
Integer stuYY = Integer.parseInt(tmpStr.substring(forthIndex + 1));
Student student = new Student();
student.setStuId(stuId);
student.setStuName(stuName);
student.setStuYW(stuYW);
student.setStuSX(stuSX);
student.setStuYY(stuYY);
students.add(student);
tmpStr.readLine();
}
//創建一個學生實體類 封裝stuId stuName stuYW stuSx stuYY 這5個屬性。。。
//已經幫你把數據拆分出來 並以Student 對象的形式放入集合中了 接下來 給分吧 哇咔咔
Ⅷ 用Java 實現一個簡單的學生管理系統! 求代碼,求代碼!!!!
完成了,希望能幫到你
剛開始會叫你輸入編號選擇功能
import java.io.*;
public class student {
public static void main(String args[]) throws IOException{
int[] stud = {77,99,55,46,82,75,65,31,74,85};
System.out.println("請選擇功能:");//輸入編號選擇功能
System.out.println("1、輸入學號,查詢該學生成績:");
System.out.println("2、輸入成績,查詢學生學號:");
System.out.println("3、輸入學號,刪除該學生成績");
System.out.println("請選擇編號:");
BufferedReader td = new BufferedReader(new InputStreamReader(System.in));
String temp = td.readLine();
int choice = Integer.valueOf(temp);
if(choice == 1){//一為查詢學生成績
System.out.println("請輸入學號:");
BufferedReader sd = new BufferedReader(new InputStreamReader(System.in));
String temp_sd = sd.readLine();
int No = Integer.valueOf(temp_sd);
System.out.print("學號為 "+No+" 的學生成績為: " + stud[No-1] +"分");
}
if(choice == 2){//二為查詢學生編號
System.out.println("請輸入成績:");
BufferedReader sd = new BufferedReader(new InputStreamReader(System.in));
String chengji = sd.readLine();
int temp_cj = Integer.valueOf(chengji);
for(int i=0;i<stud.length;i++){
if(temp_cj == stud[i]){
System.out.print("成績為 "+ temp_cj+ "的學生的學號為: "+(i+1));
}
}
}
if(choice == 3){//三為刪除操作
System.out.println("請輸入學號:");
BufferedReader sd = new BufferedReader(new InputStreamReader(System.in));
String temp_sd = sd.readLine();
int No = Integer.valueOf(temp_sd);
stud[No-1]=0;//直接賦值為0,不刪除學生
System.out.print("學號為 "+No+" 的學生成績為: " + stud[No-1] +"分");
}
}
}
Ⅸ java控制台學生信息管理系統
你好,你要的學生信息管理系統。
(1) Student類
importjava.io.Serializable;
/**
*@authorliuxe
*@sinceJDK1.7.0_79
*/
{
privateintstuId;
privateStringname;
privateStringmajor;
privateStringsex;
privateStringcontactWay;
publicintgetStuId(){
returnstuId;
}
publicvoidsetStuId(intstuId){
this.stuId=stuId;
}
publicStringgetName(){
returnname;
}
publicvoidsetName(Stringname){
this.name=name;
}
publicStringgetMajor(){
returnmajor;
}
publicvoidsetMajor(Stringmajor){
this.major=major;
}
publicStringgetSex(){
returnsex;
}
publicvoidsetSex(Stringsex){
this.sex=sex;
}
publicStringgetContactWay(){
returncontactWay;
}
publicvoidsetContactWay(StringcontactWay){
this.contactWay=contactWay;
}
}
(2) StuMis類
importjava.io.*;
importjava.util.ArrayList;
importjava.util.List;
/**
*@authorliuxe
*@sinceJDK1.7.0_79
*/
publicclassStuMis{
publicstaticList<Student>studentList=newArrayList<Student>();
publicstaticbooleanadd(Studentstudent){
returnstudentList.add(student);
}
publicstaticbooleanremove(Studentstudent){
returnstudentList.remove(student);
}
publicstaticbooleanupdate(Studentstudent){
for(Studentdto:studentList){
if(student.getStuId()==dto.getStuId()){
studentList.remove(dto);
}
}
returnstudentList.add(student);
}
(intid){
for(Studentdto:studentList){
if(id==dto.getStuId()){
returndto;
}
}
returnnull;
}
publicstaticList<Student>queryByName(Stringname){
List<Student>returnList=newArrayList<Student>();
for(Studentdto:studentList){
if(name.equals(dto.getName())){
returnList.add(dto);
}
}
returnreturnList;
}
publicstaticvoidsaveToFile(){
try{
ObjectOutputStreamoo=newObjectOutputStream(newFileOutputStream(
newFile("."+File.separator+"student.dat")));
oo.writeObject(studentList);
}catch(Exceptionex){
ex.printStackTrace();
}
}
publicstaticvoidreadFromFile(){
try{
ObjectInputStreamois=newObjectInputStream(newFileInputStream(
newFile("."+File.separator+"student.dat")));
studentList=(List<Student>)ois.readObject();
}catch(Exceptionex){
ex.printStackTrace();
}
}
}
(3)、StuMisTest類:主函數測試學生信息管理系統
importjava.util.List;
/**
*@authorliuxe
*@sinceJDK1.7.0_79
*/
publicclassStuMisTest{
publicstaticvoidmain(String[]args){
Studentstudent=newStudent();
student.setStuId(1);
student.setName("AAA");
student.setMajor("AAAA");
student.setSex("A");
student.setContactWay("AA");
Studentstudent2=newStudent();
student2.setStuId(2);
student2.setName("BBB");
student2.setMajor("BBBB");
student2.setSex("B");
student2.setContactWay("BB");
Studentstudent3=newStudent();
student3.setStuId(3);
student3.setName("CCC");
student3.setMajor("CCCC");
student3.setSex("C");
student3.setContactWay("CC");
//A、增加一個學生記錄
StuMis.add(student);
StuMis.add(student2);
StuMis.add(student3);
//B、刪除一個學生記錄
StuMis.remove(student2);
//C、修改學生信息
student.setMajor("DDDD");
StuMis.update(student);
//D、根據學號查找學生
StudentstudentXX=StuMis.queryByStuId(3);
//E、根據姓名查找學生。。。
List<Student>studentOO=StuMis.queryByName("AAA");
//F、將集合中所有學生信息存儲到student.dat中。
StuMis.saveToFile();
//G、再次運行系統時載入student.dat中的學生信息,後支持A~E基本操作。
StuMis.readFromFile();
}
}
Ⅹ 簡單的JAVA學生管理系統代碼
package com.test;
import java.util.Scanner;
import java.util.Arrays;
public class ResultMgr{
public static void showMenu(){
System.out.println("--------歡迎使用成績管理器ver1.0---------");
System.out.println("-----------1. 增加成績-------------------");
System.out.println("-----------2. 顯示所有成績(升序處理)-----");
System.out.println("-----------3. 根據下標索引刪除成績-------");
System.out.println("-----------0. 離開系統-------------------");
}
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
double[] results = new double[3];
int index = 0;
do{
showMenu();
int ling = sc.nextInt();
switch(ling){
case 1:{
System.out.println("進入增加成績流程");
System.out.println("請錄入學生成績,格式為xx.x");
double r = sc.nextDouble();
results[index++] = r;
System.out.println(Arrays.toString(results));
break;
}
case 2:{
System.out.println("進入顯示成績流程,冒泡進行中...");
break;
}
case 3:{
System.out.println("進入刪除成績流程");
break;
}
default:{
System.out.println("");
System.exit(0);
}
}
}while(true);
}
}