用java基础语言编写一个班级学生管理系统

/*需求:学生管理系统
 功能:对学生的信息进行管理
 1 添加学生信息;2 删除学生信息;3修改学生信息;4 查找指定学生信息;5 查找所有学生信息
    涉及到的数据:
    管理员:一个(账号-String;密码-String);
    学生的信息:
    学号:String;姓名:String;
    存储数据:两个数组(学号;姓名)-String
 */

import java.util.Scanner;
class StuManager
{
    public static void main(String[] args)
    {
        System.out.println("*********************");
        System.out.println("*                   *");
        System.out.println("* 学生信息管理系统  *");
        System.out.println("*                   *");
        System.out.println("*********************");
        while(true){
            System.out.println("1 登录系统;   2 结束系统");
            Scanner input=new Scanner(System.in);
            String log=input.nextLine();
            String[] stuNames=new String[30];
            String[] stuIds=new String[30];
            int count=0;
            if("1".equals(log)){
                //登录界面
                while(true){
                    boolean tag=true;
                    System.out.println("请输入账号");
                    String account =input.nextLine();
                    System.out.println("请输入密码");
                    String password =input.nextLine();
                    if("admin".equals(account)&&"123456".equals(password)){
                        //功能主界面
                        while(tag){
                            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("*********************");
                            System.out.print("请选择功能:");
                            String function =input.nextLine();
                            switch(function){
                                case "1":
                                    System.out.println("请输入学生学号:");
                                    String stuId =input.nextLine();
                                    System.out.println("请输入学生姓名:");
                                    String stuName =input.nextLine();
                                    stuNames[count]=stuName;
                                    stuIds[count]=stuId;
                                    count++;
                                    break;
                                case "2":
                                    boolean label=false;
                                    System.out.println("请输入要删除的学生学号:");
                                    String stuId1 =input.nextLine();
                                    for(int i=0;i<count;i++){
                                        if(stuIds[count-1].equals(stuId1)){
                                            count--;
                                            System.out.println("删除成功");
                                            label=true;
                                        }
                                        else if(stuIds[i].equals(stuId1)){
                                            for(int j=i;j<count-1;j++){
                                                stuIds[j]=stuIds[j+1];
                                                stuNames[j]=stuNames[j+1];
                                                count--;
                                                System.out.println("删除成功");
                                                label=true;
                                            }
                                        }
                                    }
                                    if(!label){
                                        System.out.println("查无此人,请重新操作");
                                    }
                                    break;
                                case "3":
                                    boolean flag=false;
                                    System.out.println("请输入要修改的学生学号:");
                                    String stuId2 =input.nextLine();
                                    for(int i=0;i<count;i++){
                                        if(stuIds[i].equals(stuId2)){
                                            System.out.println("请输入要修改后的学生学号:");
                                            String stuName2 =input.nextLine();
                                            stuNames[i]=stuName2;
                                            flag=true;
                                        }
                                    }
                                    if(!flag){
                                        System.out.println("查无此人,请重新操作");
                                    }
                                    break;
                                case "4":
                                    for(int i=0;i<count;i++){
                                        System.out.println("学号:"+stuIds[i]+" 姓名:"+stuNames[i]);
                                    }
                                    break;
                                case "5":
                                    boolean mark=false;
                                    System.out.println("请输入要查找的学生学号:");
                                    String stuId3 =input.nextLine();
                                    for(int i=0;i<count;i++){
                                        if(stuIds[i].equals(stuId3)){
                                            System.out.println("学号:"+stuIds[i]+" 姓名:"+stuNames[i]);
                                            mark=true;
                                        }
                                    }
                                    if(!mark){
                                        System.out.println("查无此人,请重新操作");
                                    }
                                    break;
                                case "6":
                                    tag=false;
                                    break;
                                case "7":
                                    System.exit(0);
                                    break;
                                default:
                                    System.out.println("操作不正确,请重新操作");
                                    break;
                            }
                        }
                    }
                    else{
                        System.out.println("账号或密码不正确,请重新输入");
                    }
                }
            }
            else if("2".equals(log)){
                return;
            }
            else{
                System.out.println("操作不正确,请重新操作");
            }
        }
    }
}
  • 9
    点赞
  • 28
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
中国现在教育事业的发展迅猛,高等院校的数量和规模不断的扩大。与此同时,根据时代的要求,管理,特别是对日益增多的学生的管理,对学校的发展起着不可忽视的作用。而班主任(辅导老师)在学生的管理中有着承上启下的枢纽地位,这一角色的重要性也日渐突出起来。学校与学生之间沟通途径的建立、对学生的具体管理措施的实施等都是通过班主任的工作得以体现和贯彻执行的,如果班主任这个环节的工作做的好,其对学生工作的总体管理和发展都具有不可估量的好处。因此,越来越多的学校对班主任这一角色也越来越重视,一些院校专门对班主任进行一系列培训,并且由原来的一个系甚至一个院配备一名辅导员增加至每个班级一名班主任。 与上述管理需求不符的是:针对班主任工作的配套管理软件严重缺乏。虽然,已有很多较成熟的学生管理方面的软件,但这些软件主要是实现了教学和教务两个方面的数字化管理,而在目前国内已有的学生管理系统中,具体到班主任管理班级这个方面的管理软件基本上是一片空白。 实际上,一方面,班主任工作的特点是事多、琐碎、繁杂,但工作程序是有序。因而,在当今科技高度发达的信息社会,开发一个适合班主任工作的管理软件,提高办公质量,加强班级管理,是适应学校各方面发展的要求,是学生管理工作中急需解决的问题。
好的,学生宿舍管理系统主要包括以下几个模块: 1. 学生信息管理模块:包括学生基本信息(学号、姓名、性别、年龄、班级等)的增删改查功能。 2. 宿舍信息管理模块:包括宿舍基本信息(宿舍号、楼层、床位数等)的增删改查功能。 3. 入住管理模块:包括学生入住宿舍、退宿等功能。 4. 维修管理模块:包括宿舍维修申报、维修记录查询等功能。 5. 统计报表模块:包括学生入住情况、宿舍维修情况等统计报表功能。 下面是一个简单的学生宿舍管理系统Java代码示例: ```java import java.util.ArrayList; import java.util.Scanner; public class DormitoryManagementSystem { // 定义ArrayList集合存储学生和宿舍信息 private static ArrayList<Student> students = new ArrayList<>(); private static ArrayList<Dormitory> dormitories = new ArrayList<>(); public static void main(String[] args) { Scanner input = new Scanner(System.in); 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("0. 退出系统"); System.out.print("请选择操作:"); int choice = input.nextInt(); switch (choice) { case 0: System.out.println("谢谢使用,再见!"); System.exit(0); break; case 1: studentInfoManagement(); break; case 2: dormitoryInfoManagement(); break; case 3: checkInManagement(); break; case 4: repairManagement(); break; case 5: statisticReport(); break; default: System.out.println("输入有误,请重新选择!"); break; } } } // 学生信息管理模块 public static void studentInfoManagement() { Scanner input = new Scanner(System.in); while (true) { System.out.println("学生信息管理"); System.out.println("1. 添加学生信息"); System.out.println("2. 修改学生信息"); System.out.println("3. 删除学生信息"); System.out.println("4. 查询学生信息"); System.out.println("0. 返回上一级菜单"); System.out.print("请选择操作:"); int choice = input.nextInt(); switch (choice) { case 0: return; case 1: addStudent(); break; case 2: modifyStudent(); break; case 3: deleteStudent(); break; case 4: queryStudent(); break; default: System.out.println("输入有误,请重新选择!"); break; } } } // 添加学生信息 public static void addStudent() { Scanner input = new Scanner(System.in); System.out.print("请输入学号:"); String id = input.next(); System.out.print("请输入姓名:"); String name = input.next(); System.out.print("请输入性别:"); String gender = input.next(); System.out.print("请输入年龄:"); int age = input.nextInt(); System.out.print("请输入班级:"); String className = input.next(); Student student = new Student(id, name, gender, age, className); students.add(student); System.out.println("添加成功!"); } // 修改学生信息 public static void modifyStudent() { Scanner input = new Scanner(System.in); System.out.print("请输入要修改的学生学号:"); String id = input.next(); for (Student student : students) { if (student.getId().equals(id)) { System.out.print("请输入新姓名:"); String name = input.next(); System.out.print("请输入新性别:"); String gender = input.next(); System.out.print("请输入新年龄:"); int age = input.nextInt(); System.out.print("请输入新班级:"); String className = input.next(); student.setName(name); student.setGender(gender); student.setAge(age); student.setClassName(className); System.out.println("修改成功!"); return; } } System.out.println("未找到该学生!"); } // 删除学生信息 public static void deleteStudent() { Scanner input = new Scanner(System.in); System.out.print("请输入要删除的学生学号:"); String id = input.next(); for (Student student : students) { if (student.getId().equals(id)) { students.remove(student); System.out.println("删除成功!"); return; } } System.out.println("未找到该学生!"); } // 查询学生信息 public static void queryStudent() { Scanner input = new Scanner(System.in); System.out.print("请输入要查询的学生学号:"); String id = input.next(); for (Student student : students) { if (student.getId().equals(id)) { System.out.println("学号\t姓名\t性别\t年龄\t班级"); System.out.println(student.getId() + "\t" + student.getName() + "\t" + student.getGender() + "\t" + student.getAge() + "\t" + student.getClassName()); return; } } System.out.println("未找到该学生!"); } // 宿舍信息管理模块 public static void dormitoryInfoManagement() { Scanner input = new Scanner(System.in); while (true) { System.out.println("宿舍信息管理"); System.out.println("1. 添加宿舍信息"); System.out.println("2. 修改宿舍信息"); System.out.println("3. 删除宿舍信息"); System.out.println("4. 查询宿舍信息"); System.out.println("0. 返回上一级菜单"); System.out.print("请选择操作:"); int choice = input.nextInt(); switch (choice) { case 0: return; case 1: addDormitory(); break; case 2: modifyDormitory(); break; case 3: deleteDormitory(); break; case 4: queryDormitory(); break; default: System.out.println("输入有误,请重新选择!"); break; } } } // 添加宿舍信息 public static void addDormitory() { Scanner input = new Scanner(System.in); System.out.print("请输入宿舍号:"); String number = input.next(); System.out.print("请输入楼层:"); int floor = input.nextInt(); System.out.print("请输入床位数:"); int capacity = input.nextInt(); Dormitory dormitory = new Dormitory(number, floor, capacity); dormitories.add(dormitory); System.out.println("添加成功!"); } // 修改宿舍信息 public static void modifyDormitory() { Scanner input = new Scanner(System.in); System.out.print("请输入要修改的宿舍号:"); String number = input.next(); for (Dormitory dormitory : dormitories) { if (dormitory.getNumber().equals(number)) { System.out.print("请输入新楼层:"); int floor = input.nextInt(); System.out.print("请输入新床位数:"); int capacity = input.nextInt(); dormitory.setFloor(floor); dormitory.setCapacity(capacity); System.out.println("修改成功!"); return; } } System.out.println("未找到该宿舍!"); } // 删除宿舍信息 public static void deleteDormitory() { Scanner input = new Scanner(System.in); System.out.print("请输入要删除的宿舍号:"); String number = input.next(); for (Dormitory dormitory : dormitories) { if (dormitory.getNumber().equals(number)) { dormitories.remove(dormitory); System.out.println("删除成功!"); return; } } System.out.println("未找到该宿舍!"); } // 查询宿舍信息 public static void queryDormitory() { Scanner input = new Scanner(System.in); System.out.print("请输入要查询的宿舍号:"); String number = input.next(); for (Dormitory dormitory : dormitories) { if (dormitory.getNumber().equals(number)) { System.out.println("宿舍号\t楼层\t床位数"); System.out.println(dormitory.getNumber() + "\t" + dormitory.getFloor() + "\t" + dormitory.getCapacity()); return; } } System.out.println("未找到该宿舍!"); } // 入住管理模块 public static void checkInManagement() { Scanner input = new Scanner(System.in); System.out.print("请输入要入住的学生学号:"); String id = input.next(); for (Student student : students) { if (student.getId().equals(id)) { System.out.print("请输入要入住的宿舍号:"); String number = input.next(); for (Dormitory dormitory : dormitories) { if (dormitory.getNumber().equals(number)) { if (dormitory.getAvailableCapacity() == 0) { System.out.println("该宿舍已满!"); return; } student.setDormitory(dormitory); dormitory.addStudent(student); System.out.println("入住成功!"); return; } } System.out.println("未找到该宿舍!"); return; } } System.out.println("未找到该学生!"); } // 维修管理模块 public static void repairManagement() { Scanner input = new Scanner(System.in); System.out.print("请输入要维修的宿舍号:"); String number = input.next(); for (Dormitory dormitory : dormitories) { if (dormitory.getNumber().equals(number)) { System.out.print("请输入维修内容:"); String content = input.next(); dormitory.addRepairRecord(content); System.out.println("维修申报成功!"); return; } } System.out.println("未找到该宿舍!"); } // 统计报表模块 public static void statisticReport() { Scanner input = new Scanner(System.in); while (true) { System.out.println("统计报表"); System.out.println("1. 学生入住情况"); System.out.println("2. 宿舍维修情况"); System.out.println("0. 返回上一级菜单"); System.out.print("请选择操作:"); int choice = input.nextInt(); switch (choice) { case 0: return; case 1: studentCheckInReport(); break; case 2: dormitoryRepairReport(); break; default: System.out.println("输入有误,请重新选择!"); break; } } } // 学生入住情况统计报表 public static void studentCheckInReport() { System.out.println("学号\t姓名\t性别\t年龄\t班级\t宿舍号\t楼层\t床位数"); for (Student student : students) { Dormitory dormitory = student.getDormitory(); if (dormitory != null) { System.out.println(student.getId() + "\t" + student.getName() + "\t" + student.getGender() + "\t" + student.getAge() + "\t" + student.getClassName() + "\t" + dormitory.getNumber() + "\t" + dormitory.getFloor() + "\t" + dormitory.getCapacity()); } } } // 宿舍维修情况统计报表 public static void dormitoryRepairReport() { System.out.println("宿舍号\t楼层\t床位数\t维修记录"); for (Dormitory dormitory : dormitories) { System.out.print(dormitory.getNumber() + "\t" + dormitory.getFloor() + "\t" + dormitory.getCapacity()); for (String repairRecord : dormitory.getRepairRecords()) { System.out.print("\t" + repairRecord); } System.out.println(); } } } class Student { private String id; private String name; private String gender; private int age; private String className; private Dormitory dormitory; public Student(String id, String name, String gender, int age, String className) { this.id = id; this.name = name; this.gender = gender; this.age = age; this.className = className; } public String getId() { return id; } public void setId(String id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getGender() { return gender; } public void setGender(String gender) { this.gender = gender; } public int getAge() { return age; } public void setAge(int age) { this.age = age; } public String getClassName() { return className; } public void setClassName(String className) { this.className = className; } public Dormitory getDormitory() { return dormitory; } public void setDormitory(Dormitory dormitory) { this.dormitory = dormitory; } } class Dormitory { private String number; private int floor; private int capacity; private ArrayList<Student> students = new ArrayList<>(); private ArrayList<String> repairRecords = new ArrayList<>(); public Dormitory(String number, int floor, int capacity) { this.number = number; this.floor = floor; this.capacity = capacity; } public String getNumber() { return number; } public void setNumber(String number) { this.number = number; } public int getFloor() { return floor; } public void setFloor(int floor) { this.floor = floor; } public int getCapacity() { return capacity; } public void setCapacity(int capacity) { this.capacity = capacity; } public int getAvailableCapacity() { return capacity - students.size(); } public void addStudent(Student student) { students.add(student); } public ArrayList<String> getRepairRecords() { return repairRecords; } public void addRepairRecord(String content) { repairRecords.add(content); } } ``` 注意,这只是一个简单的示例代码,实际开发中还需要根据需求进行适当的修改和完善。同时,还需要进行数据存储和界面设计等方面的开发。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值