• 学生管理系统


    package 练习;
    
    import java.util.Scanner;
    
    import javax.swing.JOptionPane;
    
    public class ATM1 {
        public static int xuehao[] = new int[10];
        public static String name[] = new String[10];
        public static int chengji[] = new int[10];
        public static int i = 0;
    
        public static void main(String[] args) {
            JOptionPane.showMessageDialog(null, "欢迎光临");
            String zhanghu = "123456";
            String mima = "123456";
            boolean iso = denglu(zhanghu, mima);
            if (iso) {
                while (true) {
                    String b = JOptionPane.showInputDialog(null,
                            "1、添加
    2、显示
    3、删除
    4、修改
    5、排序
    6、查询
    7");
                    int a = Integer.parseInt(b);
                    switch (a) {
                    case 1:
                        tianjia();
                        break;
                    case 2:
                        xianshi();
                        break;
                    case 3:
                        shanchu();
                        break;
                    case 4:
                        xiugai();
                        break;
                    case 5:
                        paixu();
                        break;
                    case 6:
                        chaxu();
                        break;
                    case 7:
                        System.exit(0);
                        ;
                        break;
                    default:
                        JOptionPane.showMessageDialog(null, "只能输入1-7");
                    }
                }
            }
        }
    //查询 方法
        private static void chaxu() {
            int cz = chazhao();
            if (cz != -1) {
                JOptionPane.showMessageDialog(null, xuehao[cz] + name[cz]
                        + chengji[cz]);
    
            }
        }
    //排序方法
        private static void paixu() {
            for (int n = 0; n < i; n++) {
                for (int j = n + 1; j < i; j++) {
                    if (chengji[n] < chengji[j]) {
                        int s = chengji[n];
                        chengji[n] = chengji[j];
                        chengji[j] = s;
                        String xm = name[n];
                        name[n] = name[j];
                        name[j] = xm;
                        int xh = xuehao[n];
                        xuehao[n] = xuehao[j];
                        xuehao[j] = s;
                    }
                }
            }
            xianshi();
    
        }
    //修改方法
        private static void xiugai() {
            int n = chazhao();
            if (n != -1) {
                String str = JOptionPane.showInputDialog(null, "请输入修改的学号");
                String str1 = JOptionPane.showInputDialog(null, "请输入修改的姓名");
                String str2 = JOptionPane.showInputDialog(null, "请输入修改的成绩");
                xuehao[n] = Integer.parseInt(str);
                name[n] = str1;
                chengji[n] = Integer.parseInt(str2);
            }
        }
    //删除方法
        private static void shanchu() {
            int s = chazhao();
            if (s != -1) {
                for (int n = s; n < i; n++) {
                    xuehao[n] = xuehao[n + 1];
                    name[n] = name[n + 1];
                    chengji[n] = chengji[n + 1];
                    i--;
                }
            }
        }
    //显示方法
        private static void xianshi() {
            String info = "";
            for (int n = 0; n < i; n++) {
                info += xuehao[n] + name[n] + chengji[n] + "
    ";
            }
            JOptionPane.showMessageDialog(null, info);
        }
    //添加方法
        private static void tianjia() {
            String str = JOptionPane.showInputDialog(null, "请输入学号");
            String str1 = JOptionPane.showInputDialog(null, "请输入姓名");
            String str2 = JOptionPane.showInputDialog(null, "请输入成绩");
            xuehao[i] = Integer.parseInt(str);
            name[i] = str1;
            chengji[i] = Integer.parseInt(str2);
            i++;
        }
    //登陆方法
        public static boolean denglu(String zhanghu, String mima) {
            for (int n = 3; n > 0; n--) {
                String str = JOptionPane.showInputDialog(null, "请输入账户");
                String str1 = JOptionPane.showInputDialog(null, "请输入密码");
                if (str.equals(str1) && str1.equals(str1)) {
                    return true;
                }
                if (n == 1) {
                    JOptionPane.showMessageDialog(null, "非法输入");
                    return false;
                }
                JOptionPane.showMessageDialog(null, "你的输入有误,请重新输入" + (n - 1));
            }
            return false;
        }
    //查找方法
        public static int chazhao() {
            int index = -1;
            String str = JOptionPane.showInputDialog(null, "请输入要查找的人");
            for (int n = 0; n < i; n++) {
                if (str.equals(name[n])) {
                    return n;
                }
                JOptionPane.showMessageDialog(null, "查无此人");
            }
            return -1;
        }
    }
  • 相关阅读:
    盯盘的基本技巧
    教你一招短线选股法
    卖咖啡8.0i企业版,详细设置规则。让杀毒软件发挥真正的作用!
    PHP获取 当前页面名称、主机名、URL完整地址、URL参数、获取IP
    mysql乱码处理一则
    word2007怎样显示预览快速打印按扭
    一个简单功能强大的Google Map 搜索源码
    Google和百度、雅虎的站内搜索代码
    FCKeditor 2.5 使用方法 配置ASP上传功能 & PHP实例:FCKeditor2.6 的配置和使用方法
    PHP获取当前url路径的函数及服务器变量:QUERY_STRING、REQUEST_URI、SCRIPT...
  • 原文地址:https://www.cnblogs.com/qhmm/p/5854584.html
Copyright © 2020-2023  润新知