| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 777 人关注过本帖
标题:啊,求大神帮看程序【学生管理系统】,该怎么修改呢?
只看楼主 加入收藏
菁城
Rank: 1
等 级:新手上路
帖 子:19
专家分:0
注 册:2015-3-13
结帖率:50%
收藏
已结贴  问题点数:10 回复次数:4 
啊,求大神帮看程序【学生管理系统】,该怎么修改呢?
/*
 * Main.java
 *
 * Created on 2010年1月12日, 下午4:22
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package javaapplication1;

/**
 *
 * @author Administrator
 */
public class Main {
   
    /** Creates a new instance of Main */
    public Main() {
    }
   
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        import java.util.*;
        public class Test {//主程序
            public static void main(String[] args){
                Scanner in = new Scanner(System.in);
                System.out.println("------请定义学生的人数:------");
                Student[] stuArr = new Student[in.nextInt()];
                Admin adminStu = new Admin();
                while(true){
                    System.out.println("-----请选择你要执行的功能-----");
                    System.out.println("10:添加一个学生");
                    System.out.println("11:查找一个学生");
                    System.out.println("12:根据学生编号更新学生基本信息");
                    System.out.println("13:根据学生编号删除学生");
                    System.out.println("14:根据编号输入学生各门成绩");
                    System.out.println("15:根据某门成绩进行排序");
                    System.out.println("16:根据总分进行排序");
                    System.out.println("99:退出系统");
                    String number = in.next();
                    if(number.equals("10")){
                        System.out.println("请输入学生的编号:");
                        int num = in.nextInt();
                        System.out.println("请输入学生的姓名:");
                        String name = in.next();
                        System.out.println("请输入学生的年龄:");
                        int age = in.nextInt();
                        adminStu.Create(num,name,age,stuArr);//添加学生
                    }else if(number.equals("11")){
                        System.out.println("执行查找学生基本信息的操作");
                        System.out.println("请输入学生的编号进行查找:");
                        int num = in.nextInt();
                        adminStu.find(num,stuArr);//查找学生
                    }else if(number.equals("12")){
                        System.out.println("执行更新学员的基本信息操作");
                        System.out.println("请输入学生的编号:");
                        int num = in.nextInt();
                        System.out.println("请输入学生的姓名:");
                        String name = in.next();
                        System.out.println("请输入学生的年龄:");
                        int age = in.nextInt();
                        adminStu.update(num,name,age,stuArr);//更新学生基本信息
                    }else if(number.equals("13")){
                        System.out.println("执行删除学生操作");
                        System.out.println("请输入学生编号:");
                        int num = in.nextInt();
                        adminStu.delete(num,stuArr);//删除学生
                    }else if(number.equals("14")){
                        System.out.println("执行输入成绩操作");
                        System.out.println("请输入学生编号:");
                        int num = in.nextInt();
                        adminStu.input(num, stuArr);//输入成绩
                    }else if(number.equals("15")){
                        System.out.println("执行根据某科目成绩排序操作");
                        System.out.println("请选择需要排序的科目名(1.java 2.C# 3.html 4.sql):");
                        int num = in.nextInt();
                        adminStu.courseSort(num,stuArr);//按科目排序
                    }else if(number.equals("16")){
                        System.out.println("执行根据总分排序操作");
                        adminStu.sumSort(stuArr);//按总分排序
                    }else if(number.equals("99")){
                        System.out.println("--------程序已退出--------");
                        //break;
                        System.exit(0);
                    }
                }
            }
        }
        public class Student {//学生类
            private int num;
            private String name;
            private int age;
            private int java;
            private int C;
            private int html;
            private int sql;
            private int sum;
            private int avg;
            public int getNum() {
                return num;
            }
            public void setNum(int num) {
                this.num = num;
            }
            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 int getJava() {
                return java;
            }
            public void setJava(int java) {
                this.java = java;
            }
            public int getC() {
                return C;
            }
            public void setC(int c) {
                C = c;
            }
            public int getHtml() {
                return html;
            }
            public void setHtml(int html) {
                this.html = html;
            }
            public int getSql() {
                return sql;
            }
            public void setSql(int sql) {
                this.sql = sql;
            }
            public int getSum() {
                return sum;
            }
            public void setSum() {
                this.sum = this.java+this.C+this.html+this.sql;
            }
            public int getAvg() {
                return avg;
            }
            public void setAvg() {
                this.avg = this.sum/4;
            }
            public String toString(){
                String str = "\t"+this.num+"\t"+this.name+"\t"+this.age+"\t" +this.java+"\t"+this.C+"\t"+this.html+"\t"+this.sql+"\t"+this.sum+"\t"+this.avg;
                return str;
            }
        }
        
        import java.util.*;
        public class Admin {//用来管理学生的一个类
            String msg = "\t编号\t姓名\t年龄\tjava\tC#\thtml\tsql\t总分\t平均分";
            public void print(Student[] arr){//刷新数据的方法
                System.out.println(msg);
                for(int i=0;i<arr.length;i++){
                    if(arr[i]!=null){
                        arr[i].setSum();
                        arr[i].setAvg();
                        System.out.println(arr[i]);
                    }
                }
            }
            public boolean exist(int num,Student stu){//判断学生是否存在的方法
                if(stu!=null){
                    if(stu.getNum()==num){
                        return true;
                    }
                    else{
                        return false;
                    }
                    return false;
                }
                public void Create(int num,String name,int age,Student[] arr){//添加学生的方法
                    Student stu = new Student();
                    stu.setNum(num);
                    stu.setName(name);
                    stu.setAge(age);
                    int i = this.setIndex(arr);
                    if(i==99999){
                        System.out.println("学生人数已添满,不能再添加了");
                    }
                    else{
                        arr[i]=stu;
                    }
                    this.print(arr);
                }
                public int setIndex(Student[] arr){//返回数组为空的下标
                    for(int i=0;i<arr.length;i++){
                        if(arr[i]==null){
                            return i;
                        }
                    }
                    return 99999;
                }
                public void find(int num,Student[] arr){//查询学生的方法
                    for(int i=0;i<arr.length;i++){//判断学生是否存在
                        if(this.exist(num,arr[i])==true){
                            System.out.println(msg);
                            System.out.println(arr[i]);
                            return;
                        }
                    }
                    System.out.println("-----没有这个学生的存在-----");
                }
                public void update(int num,String name,int age,Student[] arr){//更新学生基本信息的方法
                    for(int i=0;i<arr.length;i++){
                        if(this.exist(num, arr[i])==true){
                            arr[i].setName(name);
                            arr[i].setAge(age);
                            System.out.println("--------更新学生信息成功!-------");
                            this.print(arr);
                            return;
                        }
                    }
                    System.out.println("------没找到这个学生更新信息失败------");
                }
                public void delete(int num,Student[] arr){//删除学生的方法
                    for(int i=0;i<arr.length;i++){
                        if(this.exist(num,arr[i])){
                            arr[i] = null;
                            this.print(arr);
                            return;
                        }
                    }
                    System.out.println("您所指定编号的学生不存在");
                }
                public void input(int num,Student[] arr){//输入学生成绩的方法
                    for(int i=0;i<arr.length;i++){
                        if(this.exist(num, arr[i])){
                            Scanner in = new Scanner(System.in);
                            System.out.println("请输入"+arr[i].getName()+"java的成绩:");
                            if(in.hasNextInt()){//输入非整形数则不执行
                                arr[i].setJava(in.nextInt());
                            }else{
                                return;
                            }
                            System.out.println("请输入"+arr[i].getName()+"C#的成绩:");
                            if(in.hasNextInt()){
                                arr[i].setC(in.nextInt());
                            }else{
                                return;
                            }
                            System.out.println("请输入"+arr[i].getName()+"html的成绩:");
                            if(in.hasNextInt()){
                                arr[i].setHtml(in.nextInt());
                            }else{
                                return;
                            }
                            System.out.println("请输入"+arr[i].getName()+"sql的成绩:");
                            if(in.hasNextInt()){
                                arr[i].setSql(in.nextInt());
                            }else{
                                return;
                            }
                            this.print(arr);
                            return;
                        }
                    }
                }
                public void courseSort(int num,Student[] arr){//根据指定科目排序的方法
                    if(num==1){  //这里不能用冒泡排序(因为冒泡排序是相邻的比较,而相邻的可能不存在,那么相隔的两个就不能交换)
                        for(int i=0;i<arr.length;i++){
                            for(int j=i+1;j<arr.length;j++){
                                if(arr[i]!=null&&arr[j]!=null){
                                    if(arr[i].getJava()<arr[j].getJava()){
                                        Student t = arr[i];
                                        arr[i] = arr[j];
                                        arr[j] = t;
                                    }
                                }
                            }
                        }
                    }else if(num==2){
                        for(int i=0;i<arr.length;i++){
                            for(int j=i+1;j<arr.length;j++){
                                if(arr[i]!=null&&arr[j]!=null){
                                    if(arr[i].getC()<arr[j].getC()){
                                        Student t = arr[i];
                                        arr[i] = arr[j];
                                        arr[j] = t;
                                    }
                                }
                            }
                        }
                    }else if(num==3){
                        for(int i=0;i<arr.length;i++){
                            for(int j=i+1;j<arr.length;j++){
                                if(arr[i]!=null&&arr[j]!=null){
                                    if(arr[i].getHtml()<arr[j].getHtml()){
                                        Student t = arr[i];
                                        arr[i] = arr[j];
                                        arr[j] = t;
                                    }
                                }
                            }
                        }
                    }else if(num==4){
                        for(int i=0;i<arr.length;i++){
                            for(int j=i+1;j<arr.length;j++){
                                if(arr[i]!=null&&arr[j]!=null){
                                    if(arr[i].getSql()<arr[j].getSql()){
                                        Student t = arr[i];
                                        arr[i] = arr[j];
                                        arr[j] = t;
                                    }
                                }
                            }
                        }
                    }
                    this.print(arr);
                }
                public void sumSort(Student[] arr){//根据总分排序的方法
                    for(int i=0;i<arr.length;i++){
                        for(int j=i+1;j<arr.length;j++){
                            if(arr[i]!=null&&arr[j]!=null){
                                if(arr[i].getSum()<arr[j].getSum()){
                                    Student t = arr[i];
                                    arr[i] = arr[j];
                                    arr[j] = t;
                                }
                            }
                        }
                    }
                    this.print(arr);
                }
            }
        }
    }
   
}
搜索更多相关主题的帖子: command 管理系统 package public change command 管理系统 package public change 
2015-04-13 17:08
hhwz
Rank: 13Rank: 13Rank: 13Rank: 13
等 级:贵宾
威 望:87
帖 子:687
专家分:4502
注 册:2011-5-22
收藏
得分:0 
你要改什么?
2015-04-14 09:56
凌风zx
Rank: 8Rank: 8
来 自:万灵娱乐城
等 级:蝙蝠侠
威 望:7
帖 子:88
专家分:790
注 册:2015-4-11
收藏
得分:10 
import java.util.*;
public class Test {//主程序
            public static void main(String[] args){
                Scanner in = new Scanner(System.in);
                System.out.println("------请定义学生的人数:------");
                Student[] stuArr = new Student[in.nextInt()];
                Admin adminStu = new Admin();
                while(true){
                    System.out.println("-----请选择你要执行的功能-----");
                    System.out.println("10:添加一个学生");
                    System.out.println("11:查找一个学生");
                    System.out.println("12:根据学生编号更新学生基本信息");
                    System.out.println("13:根据学生编号删除学生");
                    System.out.println("14:根据编号输入学生各门成绩");
                    System.out.println("15:根据某门成绩进行排序");
                    System.out.println("16:根据总分进行排序");
                    System.out.println("99:退出系统");
                    String number = in.next();
                    if(number.equals("10")){
                        System.out.println("请输入学生的编号:");
                        int num = in.nextInt();
                        System.out.println("请输入学生的姓名:");
                        String name = in.next();
                        System.out.println("请输入学生的年龄:");
                        int age = in.nextInt();
                        adminStu.Create(num,name,age,stuArr);//添加学生
                    }else if(number.equals("11")){
                        System.out.println("执行查找学生基本信息的操作");
                        System.out.println("请输入学生的编号进行查找:");
                        int num = in.nextInt();
                        adminStu.find(num,stuArr);//查找学生
                    }else if(number.equals("12")){
                        System.out.println("执行更新学员的基本信息操作");
                        System.out.println("请输入学生的编号:");
                        int num = in.nextInt();
                        System.out.println("请输入学生的姓名:");
                        String name = in.next();
                        System.out.println("请输入学生的年龄:");
                        int age = in.nextInt();
                        adminStu.update(num,name,age,stuArr);//更新学生基本信息
                    }else if(number.equals("13")){
                        System.out.println("执行删除学生操作");
                        System.out.println("请输入学生编号:");
                        int num = in.nextInt();
                        adminStu.delete(num,stuArr);//删除学生
                    }else if(number.equals("14")){
                        System.out.println("执行输入成绩操作");
                        System.out.println("请输入学生编号:");
                        int num = in.nextInt();
                        adminStu.input(num, stuArr);//输入成绩
                    }else if(number.equals("15")){
                        System.out.println("执行根据某科目成绩排序操作");
                        System.out.println("请选择需要排序的科目名(1.java 2.C# 3.html 4.sql):");
                        int num = in.nextInt();
                        adminStu.courseSort(num,stuArr);//按科目排序
                    }else if(number.equals("16")){
                        System.out.println("执行根据总分排序操作");
                        adminStu.sumSort(stuArr);//按总分排序
                    }else if(number.equals("99")){
                        System.out.println("--------程序已退出--------");
                        //break;
                        System.exit(0);
                    }
                }
            }
        }




public class Student {//学生类
    private int num;
    private String name;
    private int age;
    private int java;
    private int C;
    private int html;
    private int sql;
    private int sum;
    private int avg;
    public int getNum() {
        return num;
    }
    public void setNum(int num) {
        this.num = num;
    }
    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 int getJava() {
        return java;
    }
    public void setJava(int java) {
        this.java = java;
    }
    public int getC() {
        return C;
    }
    public void setC(int c) {
        C = c;
    }
    public int getHtml() {
        return html;
    }
    public void setHtml(int html) {
        this.html = html;
    }
    public int getSql() {
        return sql;
    }
    public void setSql(int sql) {
        this.sql = sql;
    }
    public int getSum() {
        return sum;
    }
    public void setSum() {
        this.sum = this.java+this.C+this.html+this.sql;
    }
    public int getAvg() {
        return avg;
    }
    public void setAvg() {
        this.avg = this.sum/4;
    }
    public String toString(){
        String str = "\t"+this.num+"\t"+this.name+"\t"+this.age+"\t" +this.java+"\t"+this.C+"\t"+this.html+"\t"+this.sql+"\t"+this.sum+"\t"+this.avg;
        return str;
    }
}



import java.util.*;
public class Admin {//用来管理学生的一个类
    String msg = "\t编号\t姓名\t年龄\tjava\tC#\thtml\tsql\t总分\t平均分";
    public void print(Student[] arr){//刷新数据的方法
        System.out.println(msg);
        for(int i=0;i<arr.length;i++){
            if(arr[i]!=null){
                arr[i].setSum();
                arr[i].setAvg();
                System.out.println(arr[i]);
            }
        }
    }
    public boolean exist(int num,Student stu){//判断学生是否存在的方法
        if(stu!=null){
            if(stu.getNum()==num){
                return true;
            }
            else{
                return false;
            }
        }
        return false;
    }
        public void Create(int num,String name,int age,Student[] arr){//添加学生的方法
            Student stu = new Student();
            stu.setNum(num);
            stu.setName(name);
            stu.setAge(age);
            int i = this.setIndex(arr);
            if(i==99999){
                System.out.println("学生人数已添满,不能再添加了");
            }
            else{
                arr[i]=stu;
            }
            this.print(arr);
        }
        public int setIndex(Student[] arr){//返回数组为空的下标
            for(int i=0;i<arr.length;i++){
                if(arr[i]==null){
                    return i;
                }
            }
            return 99999;
        }
        public void find(int num,Student[] arr){//查询学生的方法
            for(int i=0;i<arr.length;i++){//判断学生是否存在
                if(this.exist(num,arr[i])==true){
                    System.out.println(msg);
                    System.out.println(arr[i]);
                    return;
                }
            }
            System.out.println("-----没有这个学生的存在-----");
        }
        public void update(int num,String name,int age,Student[] arr){//更新学生基本信息的方法
            for(int i=0;i<arr.length;i++){
                if(this.exist(num, arr[i])==true){
                    arr[i].setName(name);
                    arr[i].setAge(age);
                    System.out.println("--------更新学生信息成功!-------");
                    this.print(arr);
                    return;
                }
            }
            System.out.println("------没找到这个学生更新信息失败------");
        }
        public void delete(int num,Student[] arr){//删除学生的方法
            for(int i=0;i<arr.length;i++){
                if(this.exist(num,arr[i])){
                    arr[i] = null;
                    this.print(arr);
                    return;
                }
            }
            System.out.println("您所指定编号的学生不存在");
        }
        public void input(int num,Student[] arr){//输入学生成绩的方法
            for(int i=0;i<arr.length;i++){
                if(this.exist(num, arr[i])){
                    Scanner in = new Scanner(System.in);
                    System.out.println("请输入"+arr[i].getName()+"java的成绩:");
                    if(in.hasNextInt()){//输入非整形数则不执行
                        arr[i].setJava(in.nextInt());
                    }else{
                        return;
                    }
                    System.out.println("请输入"+arr[i].getName()+"C#的成绩:");
                    if(in.hasNextInt()){
                        arr[i].setC(in.nextInt());
                    }else{
                        return;
                    }
                    System.out.println("请输入"+arr[i].getName()+"html的成绩:");
                    if(in.hasNextInt()){
                        arr[i].setHtml(in.nextInt());
                    }else{
                        return;
                    }
                    System.out.println("请输入"+arr[i].getName()+"sql的成绩:");
                    if(in.hasNextInt()){
                        arr[i].setSql(in.nextInt());
                    }else{
                        return;
                    }
                    this.print(arr);
                    return;
                }
            }
        }
        public void courseSort(int num,Student[] arr){//根据指定科目排序的方法
            if(num==1){  //这里不能用冒泡排序(因为冒泡排序是相邻的比较,而相邻的可能不存在,那么相隔的两个就不能交换)
                for(int i=0;i<arr.length;i++){
                    for(int j=i+1;j<arr.length;j++){
                        if(arr[i]!=null&&arr[j]!=null){
                            if(arr[i].getJava()<arr[j].getJava()){
                                Student t = arr[i];
                                arr[i] = arr[j];
                                arr[j] = t;
                            }
                        }
                    }
                }
            }else if(num==2){
                for(int i=0;i<arr.length;i++){
                    for(int j=i+1;j<arr.length;j++){
                        if(arr[i]!=null&&arr[j]!=null){
                            if(arr[i].getC()<arr[j].getC()){
                                Student t = arr[i];
                                arr[i] = arr[j];
                                arr[j] = t;
                            }
                        }
                    }
                }
            }else if(num==3){
                for(int i=0;i<arr.length;i++){
                    for(int j=i+1;j<arr.length;j++){
                        if(arr[i]!=null&&arr[j]!=null){
                            if(arr[i].getHtml()<arr[j].getHtml()){
                                Student t = arr[i];
                                arr[i] = arr[j];
                                arr[j] = t;
                            }
                        }
                    }
                }
            }else if(num==4){
                for(int i=0;i<arr.length;i++){
                    for(int j=i+1;j<arr.length;j++){
                        if(arr[i]!=null&&arr[j]!=null){
                            if(arr[i].getSql()<arr[j].getSql()){
                                Student t = arr[i];
                                arr[i] = arr[j];
                                arr[j] = t;
                            }
                        }
                    }
                }
            }
            this.print(arr);
        }
        public void sumSort(Student[] arr){//根据总分排序的方法
            for(int i=0;i<arr.length;i++){
                for(int j=i+1;j<arr.length;j++){
                    if(arr[i]!=null&&arr[j]!=null){
                        if(arr[i].getSum()<arr[j].getSum()){
                            Student t = arr[i];
                            arr[i] = arr[j];
                            arr[j] = t;
                        }
                    }
                }
            }
            this.print(arr);
        }
}

初出茅庐
2015-04-14 16:13
菁城
Rank: 1
等 级:新手上路
帖 子:19
专家分:0
注 册:2015-3-13
收藏
得分:0 
啊,这两天都在各种忙,就没顾得上,抱歉啊,就是我怎么他都运行不了,看看是什么原因
2015-04-18 21:43
a5549877
Rank: 1
等 级:新手上路
威 望:1
帖 子:31
专家分:4
注 册:2016-10-10
收藏
得分:0 
大哥。。你卡在哪步啊
2016-10-24 20:45
快速回复:啊,求大神帮看程序【学生管理系统】,该怎么修改呢?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.043552 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved