From 647fffb4918418f9d96ccf9619c39c859ae74b58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A7=9C=E4=BC=9F=E5=B1=B1?= <2609838563@qq.com> Date: Wed, 21 Dec 2022 21:20:56 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20221221 \344\275\234\344\270\232.md" | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 "39 \345\247\234\344\274\237\345\261\261/20221221 \344\275\234\344\270\232.md" diff --git "a/39 \345\247\234\344\274\237\345\261\261/20221221 \344\275\234\344\270\232.md" "b/39 \345\247\234\344\274\237\345\261\261/20221221 \344\275\234\344\270\232.md" new file mode 100644 index 0000000..45c8b6e --- /dev/null +++ "b/39 \345\247\234\344\274\237\345\261\261/20221221 \344\275\234\344\270\232.md" @@ -0,0 +1,76 @@ +```java +import java.util.Scanner; + +public class D7 { + // 把扫描器放在最外层,让所有方法都可以用 + static Scanner sc = new Scanner(System.in); + + public static void main(String[] args) { + String[] students = new String[10]; + students[0] = "小强"; + students[1] = "大强"; + while (true) { + start(); + choicMenu(sc.nextInt(), students, sc); + } + } + + public static void start() { + System.out.println("-----------------------------" + + "\n- 欢迎使用三班的学生管理系统-" + + "\n- \t\t1.浏览所有学生信息\t\t-" + + "\n- \t\t2.添加学生信息\t\t-" + + "\n- \t\t3.修改学生信息\t\t-" + + "\n- \t\t4.删除学生信息\t\t-" + + "\n- \t\t5.查询学生信息\t\t-" + + "\n- \t\t6.退出管理系统\t\t-" + + "\n------------------------------"); + } + + public static void choicMenu(int num, String[] stu, Scanner sc) { + switch (num) { + case 1: +// System.out.println("你选择了浏览学生信息"); + viewAllStuendt(stu); + break; + case 2: + addStudent(stu); +// System.out.println("你选择了添加学生信息"); + break; + case 3: + System.out.println("你选择了修改学生信息"); + break; + case 4: + System.out.println("你选择了删除学生信息"); + break; + case 5: + System.out.println("你选择了查询学生信息"); + + break; + case 6: + System.out.println("你选择了退出管理系统"); + break; + default: + System.out.println("选项错误"); + } + } + + public static void viewAllStuendt(String[] stu) { + System.out.println("三班现有以下学生:"); + for (String name : stu) { + if (name == null) { + continue; + } + System.out.print(name + "\t"); + } + } + + public static void addStudent(String[] stu) { + System.out.println("请输入你要添加的学生:"); + String name = sc.next(); + + } +} + +``` + -- Gitee