ShaTouwin 2023-04-12 09:58 采纳率: 50%
浏览 87
已结题

JAVA程序设计 学生信息管理系统设计

学生信息管理系统设计

学生信息包括:学号,姓名,年龄,性别,出生年月,地址,电话, E-maiI等。试设计一学生信息管理系统,使之能提供以下功能: .

1、系统以菜单方式工作

2、学生信息录入功能- - -输入

3、学生信息浏览功能- --输出

4、学生信息查询功能一一算法

按学号查询

按姓名查询

5、学生信息的删除与修改(可选项)

  • 写回答

6条回答 默认 最新

  • 心寒丶 全栈领域优质创作者 2023-04-12 10:08
    关注

    网上有现成的代码,找一找就有了,可以参考下

    import java.util.ArrayList;
    import java.util.Scanner;
    
    public class StudentManagementSystem {
    private ArrayList<Student> studentList;
    
    public StudentManagementSystem() {
        studentList = new ArrayList<>();
    }
    
    public void showMenu() {
        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.println("=====================================");
    }
    
    public void addStudent() {
        Scanner input = new Scanner(System.in);
        System.out.println("请输入学生信息:");
        System.out.print("学号:");
        String id = input.nextLine();
        System.out.print("姓名:");
        String name = input.nextLine();
        System.out.print("年龄:");
        int age = input.nextInt();
        input.nextLine();
        System.out.print("性别:");
        String gender = input.nextLine();
        System.out.print("出生年月:");
        String birthday = input.nextLine();
        System.out.print("地址:");
        String address = input.nextLine();
        System.out.print("电话:");
        String phone = input.nextLine();
        System.out.print("E-mail:");
        String email = input.nextLine();
        Student student = new Student(id, name, age, gender, birthday, address, phone, email);
        studentList.add(student);
        System.out.println("学生信息录入成功!");
    }
    
    public void showStudentList() {
        if (studentList.isEmpty()) {
            System.out.println("没有学生信息!");
        } else {
            System.out.println("----------------- 学生信息列表 -----------------");
            System.out.printf("%-10s%-10s%-5s%-5s%-15s%-20s%-15s%-30s\n",
                    "学号", "姓名", "年龄", "性别", "出生年月", "地址", "电话", "E-mail");
            for (Student student : studentList) {
                System.out.println(student);
            }
            System.out.println("-------------------------------------------------");
        }
    }
    
    public void searchStudentById() {
        Scanner input = new Scanner(System.in);
        System.out.print("请输入要查询的学生学号:");
        String id = input.nextLine();
        boolean found = false;
        for (Student student : studentList) {
            if (student.getId().equals(id)) {
                System.out.println(student);
                found = true;
                break;
            }
        }
        if (!found) {
            System.out.println("没有找到该学生!");
        }
    }
    
    public void searchStudentByName() {
        Scanner input = new Scanner(System.in);
        System.out.print("请输入要查询的学生姓名:");
        String name = input.nextLine();
        boolean found = false;
        for (Student student : studentList) {
            if (student.getName().equals(name)) {
                System.out.println(student);
                found = true;
            }
        }
        if (!found) {
            System.out.println("没有找到该学生!");
        }
    }
    
    public void deleteStudent() {
        Scanner input = new Scanner(System.in);
        System.out.print("请输入要删除的学生学号:");
        String id = input.nextLine();
        boolean found = false;
        for (Student student : studentList) {
            if (student.getId().equals(id)) {
                studentList.remove(student);
                System.out.println("学生信息删除成功!");
                found = true;
                break;
            }
        }
        if (!found) {
            System.out.println("没有找到该学生!");
        }
    }
    
    public void updateStudent() {
        Scanner input = new Scanner(System.in);
        System.out.print("请输入要修改的学生学号:");
        String id = input.nextLine();
        boolean found = false;
        for (Student student : studentList) {
            if (student.getId().equals(id)) {
                System.out.print("请输入学生姓名:");
                String name = input.nextLine();
                System.out.print("请输入学生年龄:");
                int age = input.nextInt();
                input.nextLine();
                System.out.print("请输入学生性别:");
                String gender = input.nextLine();
                System.out.print("请输入学生出生年月:");
                String birthday = input.nextLine();
                System.out.print("请输入学生地址:");
                String address = input.nextLine();
                System.out.print("请输入学生电话:");
                String phone = input.nextLine();
                System.out.print("请输入学生E-mail:");
                String email = input.nextLine();
                student.setName(name);
                student.setAge(age);
                student.setGender(gender);
                student.setBirthday(birthday);
                student.setAddress(address);
                student.setPhone(phone);
                student.setEmail(email);
                System.out.println("学生信息修改成功!");
                found = true;
                break;
            }
        }
        if (!found) {
            System.out.println("没有找到该学生!");
        }
    }
    
    public void run() {
        Scanner input = new Scanner(System.in);
        int choice;
        do {
            showMenu();
            System.out.print("请输入操作序号:");
            choice = input.nextInt();
            input.nextLine();
            switch (choice) {
                case 1:
                    addStudent();
                    break;
                case 2:
                    showStudentList();
                    break;
                case 3:
                    System.out.println("1. 按学号查询");
                    System.out.println("2. 按姓名查询");
                    System.out.print("请输入查询方式:");
                    int searchChoice = input.nextInt();
                    input.nextLine();
                    if (searchChoice == 1) {
                        searchStudentById();
                    } else if (searchChoice == 2) {
                        searchStudentByName();
                    } else {
                        System.out.println("输入有误!");
                    }
                    break;
                case 4:
                    deleteStudent();
                    break;
                case 5:
                    updateStudent();
                    break;
                case 0:
                    System.out.println("谢谢使用!");
                    break;
                default:
                    System.out.println("输入有误!");
                    break;
            }
        } while (choice != 0);
    }
    
    public static void main(String[] args) {
        StudentManagementSystem system = new StudentManagementSystem();
        system.run();
    }
    }
    
    class Student {
    private String id;
    private String name;
    private int age;
    private String gender;
    private String birthday;
    private String address;
    private String phone;
    private String email;
    
    public Student(String id, String name, int age, String gender, String birthday, String address, String phone, String email) {
        this.id = id;
        this.name = name;
        this.age = age;
        this.gender = gender;
        this.birthday = birthday;
        this.address = address;
        this.phone = phone;
        this.email = email;
    }
    
    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 int getAge() {
        return age;
    }
    
    public void setAge(int age) {
        this.age = age;
    }
    
    public String getGender() {
        return gender;
    }
    
    public void setGender(String gender) {
        this.gender = gender;
    }
    
    public String getBirthday() {
        return birthday;
    }
    
    public void setBirthday(String birthday) {
        this.birthday = birthday;
    }
    
    public String getAddress() {
        return address;
    }
    
    public void setAddress(String address) {
        this.address = address;
    }
    
    public String getPhone() {
        return phone;
    }
    
    public void setPhone(String phone) {
        this.phone = phone;
    }
    
    public String getEmail() {
        return email;
    }
    
    public void setEmail(String email) {
        this.email = email;
    }
    
    @Override
    public String toString() {
        return String.format("%-10s%-10s%-5d%-5s%-15s%-20s%-15s%-30s",
                id, name, age, gender, birthday, address, phone, email);
    }
    }
    
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(5条)

报告相同问题?

问题事件

  • 系统已结题 4月20日
  • 已采纳回答 4月12日
  • 创建了问题 4月12日

悬赏问题

  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)