当前位置:首页 » 编程语言 » 学生管理系统java

学生管理系统java

发布时间: 2022-01-11 22:14:42

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);
}
}

热点内容
安卓上哪里下大型游戏 发布:2024-12-23 15:10:58 浏览:186
明日之后目前适用于什么配置 发布:2024-12-23 14:56:09 浏览:51
php全角半角 发布:2024-12-23 14:55:17 浏览:826
手机上传助手 发布:2024-12-23 14:55:14 浏览:730
什么样的主机配置吃鸡开全效 发布:2024-12-23 14:55:13 浏览:828
安卓我的世界114版本有什么 发布:2024-12-23 14:42:17 浏览:708
vbox源码 发布:2024-12-23 14:41:32 浏览:275
诗经是怎么存储 发布:2024-12-23 14:41:29 浏览:657
屏蔽视频广告脚本 发布:2024-12-23 14:41:24 浏览:417
php解析pdf 发布:2024-12-23 14:40:01 浏览:816