student

import java.util.Scanner;

 public    class Syscontrol{
    public static void main(String[] args) {
        UI.menu();
    }
 }

 class     UI    {
    public static void menu() {
        System.out.println("******************学生个人成绩管理系统***********");
        System.out.printf("\n", null);
        System.out.println("              1、成绩管理");
        System.out.println("              2、信息管理");
        System.out.println("              3、退出系统");
        System.out.printf("\n", null);
        System.out.println("************************************************");
        System.out.println("请输入功能编号(1-3):");
        Scanner r0 = new Scanner(System.in);
        int i = r0.nextInt();
        switch(i){
            case 1: grademenu();                    break;
            case 2: stumenu();                break;
            case 3:
                System.out.println("再见!");
                break;
            default:
                System.out.println("请输入数字1到3");
                try {
                    Thread.sleep(2000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                menu();
            break;
        }
        r0.close();
    }
    private static void grademenu() {
        StudentService stulist=new StudentService();
        System.out.println("******************学生个人成绩系统***************");
        System.out.printf("\n", null);
        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.printf("\n", null);
        System.out.println("************************************************");
        System.out.println("请输入功能编号(1-6):");
        Scanner r1 = new Scanner(System.in);
        int s = r1.nextInt();
        switch(s){
            case 1:
                stulist.addgrades();
                Syscontrol.main(null);
                try {
                    Thread.sleep(2000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                break;
            case 2:
                stulist.delgrades();
                Syscontrol.main(null);
                break;
            case 3:
                stulist.editgrades();
                try {
                    Thread.sleep(2000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                Syscontrol.main(null);
                break;
            case 4:
                stulist.findgrades();
                try {
                    Thread.sleep(2000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                Syscontrol.main(null);
                break;
            case 5:
                stulist.allgrades();
                try {
                    Thread.sleep(2000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                Syscontrol.main(null);
                break;
            case 6: grademenu();                            break;
            default:
                System.out.println("请输入数字1到6");
                try {
                    Thread.sleep(2000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                stumenu();
            break;
        }
        r1.close();
    }
    private static void stumenu() {
        StudentService stulist=new StudentService();
        System.out.println("******************学生个人成绩管理系统***********");
        System.out.printf("\n", null);
        System.out.println("              1、显示学生信息");
        System.out.println("              2、修改学生信息");
        System.out.println("              3、返回上一系统");
        System.out.printf("\n", null);
        System.out.println("************************************************");
        System.out.println("请输入功能编号(1-3):");
        Scanner r2 = new Scanner(System.in);
        int t = r2.nextInt();
        switch(t){
            case 1:
                stulist.showstu();
                try {
                    Thread.sleep(2000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                Syscontrol.main(null);
                break;
            case 2:
                stulist.editstu();
                try {
                    Thread.sleep(2000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                Syscontrol.main(null);
                break;
            case 3:
                menu();
                break;
            default:
                System.out.println("请输入数字1到3");
                try {
                    Thread.sleep(2000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                stumenu();
            break;
        }
        r2.close();
    }
}
class Student{
    private String stuno;
    private String name;
    private String classes;
    private String rtime;
    Scores subjects[];
    private static int itemCount =0;

    Student(){
        itemCount++;
    }
    Student(String stuno,String name,String classes,String rtime){
        this.stuno = stuno;
        this.name = name;
        this.classes = classes;
        this.rtime = rtime;
        itemCount++;
    }
    Student(Student aItem){
        this(aItem.stuno,aItem.name,aItem.classes,aItem.rtime);
        itemCount++;
    }

    public Student(String stuno,String name,String classes,String rtime, Scores[] sub) {
        this.stuno = stuno;
        this.name = name;
        this.classes = classes;
        this.rtime = rtime;
        this.subjects=sub;
        itemCount++;
    }
    public  String getStuno() {
        return stuno;
    }
    public void setStuno(String stuno) {
        this.stuno = stuno;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getClasses() {
        return classes;
    }
    public void setClasses(String classes) {
        this.classes = classes;
    }
    public String getRtime() {
        return rtime;
    }
    public void setRtime(String rtime) {
        this.rtime = rtime;
    }

    public static int getItemCount() {
        return itemCount;
    }
    public Scores[] getSubjects() {
        return subjects;
    }
    public void setSubjects(Scores[] subjects) {
        this.subjects = subjects;
    }
    public String toString(){
        return stuno+" "+name+" "+classes+" "+rtime;
    }

}
class Scores{
    private String cno;
    private String cname;
    private String cgrades;
    private String cscore;
    Scores(){

    }
    Scores(String cno,String cname,String cgrades,String cscore){
        this.cno = cno;
        this.cname = cname;
        this.cgrades=cgrades;
        this.cscore=cscore;
    }
    public String getCno() {
        return cno;
    }
    public void setCno(String cno) {
        this.cno = cno;
    }
    public String getCname() {
        return cname;
    }
    public void setCname(String cname) {
        this.cname = cname;
    }
    public String getCscore() {
        return cscore;
    }
    public void setCscore(String cscore) {
        this.cscore = cscore;
    }
    public String getCgrades() {
        return cgrades;
    }
    public void setCgrades(String cgrades) {
        this.cgrades = cgrades;
    }

}
    class StudentService{
        private Student stu[]=new Student[100];
        private Scores sub[]=new Scores[100];
        private static int stutotal;
        private static int subtotal;

        public static int getStutotal() {
            return stutotal;
        }
        public static int getSubtotal() {
            return subtotal;
        }
        public StudentService(){
            sub[0]=new Scores("1","Math"," 60","4");
            sub[1]=new Scores("2","English"," 60","3.5");
            sub[2]=new Scores("3","Chinese"," 60","3");
            subtotal=3;
            stu[0]=new Student("1","xu","12-1","2012",sub);
            stu[1]=new Student("2","yu","12-1","2012",sub);
            stu[2]=new Student("3","su","12-1","2012",sub);
            stutotal=3;
        }

        public  boolean showstu(){
            System.out.println("请输入学生学号:");
            Scanner sc = new Scanner(System.in);
            String i = sc.nextLine();
            //sc.close();
            int j;
            for(j=0;j<stutotal;j++){
            if(stu[j].getStuno().compareTo(i)==0)
                break;
            }
            if(j<stutotal)
            {
                    System.out.println("学号为"+i+"信息为"+stu[j].toString());
                    return true;
            }else
            {
                    System.out.println("未找到您输入的学生,请检查!");
                    return false;
            }

        }
        public  void showstu(String i){
            int j;
            for(j=0;j<stutotal;j++){
                if(stu[j].getStuno().compareTo(i)==0)
                    break;
            }
            if(j<stutotal)
                     System.out.println("学号为"+i+"信息为"+stu[j].toString());
        }
        public  void editstu(){
            System.out.println("请输入要修改的学生学号:");
            Scanner sc = new Scanner(System.in);
            String i = sc.nextLine();

            int j;
            for(j=0;j<stutotal;j++){
                if(stu[j].getStuno().compareTo(i)==0)
                    break;
            }
                if(j<stutotal)
                     {
                        System.out.println("学号为"+i+"信息为"+stu[j].toString());
                        System.out.println("请输入新的学生信息,输入格式为学号,姓名,班级,入学年份。如:1 xu 12-1 2012");
                        String input =sc.nextLine();
                        String[] additem=input.split(" ");
                        if(additem.length==4){
                            delstu(i);
                            addstu(new Student(additem[0],additem[1],additem[2],additem[3]));
                            System.out.println("修改成功!");
                            showstu(i);
                            //sc.close();                        

                        }
                     }
                else
                     {
                        System.out.println("未找到您输入的学生,请检查!");
                        //sc.close();
                     }
        }
        public void delstu(String i) {
            int k=-1;
            for(int j=0;j<stutotal;j++){
                if(stu[j].getStuno().compareTo(i)==0)
                    k=j;
            }
            if(k!=-1){
                for(int s=k;s<stutotal-1;s++)
                    stu[s]=stu[s+1];
                stutotal--;
                stu[stutotal]=null;
            }
        }
        public void addstu(Student student){
            stu[stutotal]=new Student(student);
            stutotal++;
        }

        public void addgrades(){
            System.out.println("请输入学生学号:");
            Scanner sc = new Scanner(System.in);
            String i = sc.nextLine();
            for(int j=0;j<stutotal;j++){
                if(stu[j].getStuno().compareTo(i)==0){
                    System.out.println("请输入科目名称:");
                     String m = sc.nextLine();
                        for(int j1=0;j1<stutotal;j1++){
                            if(stu[j].subjects[j1].getCname().compareTo(m)==0){
                                System.out.println("请输入成绩:");
                                String n = sc.nextLine();
                                stu[j].subjects[j1].setCgrades(n);
                                System.out.println("成绩录入成功!");
                                System.out.println("学号为"+i+"科目"+m+"成绩为"+stu[j].subjects[j1].getCgrades());
                            }
                        }
                        break;
                }
            }
            //sc.close();
        }
        public void editgrades(){
            System.out.println("请输入学生学号:");
            Scanner sc = new Scanner(System.in);
            String i = sc.nextLine();
            for(int j=0;j<stutotal;j++){
                if(stu[j].getStuno().compareTo(i)==0){
                    System.out.println("请输入科目名称:");
                     String m = sc.nextLine();
                        for(int j1=0;j1<stutotal;j1++){
                            if(stu[j].subjects[j1].getCname().compareTo(m)==0){
                                System.out.println("学号为"+i+"科目"+m+"成绩为"+stu[j].subjects[j1].getCgrades());
                                System.out.println("请输入新的成绩:");
                                String n = sc.nextLine();
                                stu[j].subjects[j1].setCgrades(n);
                                System.out.println("新成绩录入成功!");
                                System.out.println("学号为"+i+"科目"+m+"新成绩为"+stu[j].subjects[j1].getCgrades());
                            }
                        }
                        break;
                }
            }

           // sc.close();
        }
        public void delgrades(){
            System.out.println("请输入学生学号:");
            Scanner sc = new Scanner(System.in);
            String i = sc.nextLine();
            for(int j=0;j<stutotal;j++){
                if(stu[j].getStuno().compareTo(i)==0){
                    System.out.println("请输入科目名称:");
                     String m = sc.nextLine();
                        for(int j1=0;j1<stutotal;j1++){
                            if(stu[j].subjects[j1].getCname().compareTo(m)==0){
                                System.out.println("学号为"+i+"科目"+m+"成绩为"+stu[j].subjects[j1].getCgrades());
                                System.out.println("确认删除吗?(1/0):");
                                int n = sc.nextInt();
                                if(n==1)
                                {
                                    stu[j].subjects[j1].setCgrades(null);
                                    System.out.println("删除成功!");
                                    System.out.println("学号为"+i+"科目"+m+"成绩为"+stu[j].subjects[j1].getCgrades());
                                }
                            }
                        }
                        break;
                }
            }

            //sc.close();
        }
        public void findgrades(){
            System.out.println("请输入学生学号:");
            Scanner sc = new Scanner(System.in);
            String i = sc.nextLine();
            for(int j=0;j<stutotal;j++){
                if(stu[j].getStuno().compareTo(i)==0){
                    System.out.println("请输入科目名称:");
                     String m = sc.nextLine();
                        for(int j1=0;j1<stutotal;j1++){
                            if(stu[j].subjects[j1].getCname().compareTo(m)==0){
                                System.out.println("学号为"+i+"科目"+m+"成绩为"+stu[j].subjects[j1].getCgrades());
                            }
                        }
                        break;
                }
            }
            //sc.close();
        }
        public void allgrades() {
            for(int j=0;j<stutotal;j++){
                System.out.println(stu[j].getName());
                for(int j1=0;j1<subtotal;j1++)
                     System.out.println(stu[j].subjects[j1].getCname()+"成绩为"+stu[j].subjects[j1].getCgrades());
            }
        }
时间: 2024-10-04 02:30:49

student的相关文章

551. 学生出席记录 Student Attendance Record I

You are given a string representing an attendance record for a student. The record only contains the following three characters: 'A' : Absent. 'L' : Late. 'P' : Present. A student could be rewarded if his attendance record doesn't contain more than o

设有一数据库,包括四个表:学生表(Student)、课程表(Course)、成绩表(Score)以及教师信息表(Teacher)。四个表的结构分别如表1-1的表(一)~表(四)所示,数据如表1-2的表(一)~表(四)所示。用SQL语句创建四个表并完成相关题目。

表(一)Student (学生表) -- Create table create table STUDENT ( sno VARCHAR2(3) not null, sname VARCHAR2(8) not null, ssex VARCHAR2(2) not null, sbirthday DATE, class VARCHAR2(5) ) tablespace USERS pctfree 10 initrans 1 maxtrans 255; -- Add comments to the

[LeetCode] Student Attendance Record I

You are given a string representing an attendance record for a student. The record only contains the following three characters: 'A' : Absent. 'L' : Late. 'P' : Present. A student could be rewarded if his attendance record doesn't contain more than o

github student pack中的digital ocean可以使用银联卡支付

申请了 github student pack却因为一直没有visita信用卡,而无法使用digital ocean的 $50,一直到今天,用中国银行借记卡成功支付. 方法是: (1)注册paypal账号,不需要绑定银行卡或信用卡. (2)打开digital ocean的welcome页面,那里会提示需要打入$5,支付方式可选“信用卡/借记卡”或者 “paypal”,选择paypal (3)进入支付页面,登陆paypal账户,输入银联卡(我的是中国银行)的卡号,然后填入后边的一些相关信息.点击“

Spring RPC 入门学习(3)-插入Student对象

Spring RPC 向后台传递对象 1. 新建RPC接口:StudentInterface.java package com.cvicse.ump.rpc.interfaceDefine; import com.cvicse.ump.student.Student; public interface StudentInterface { public Student getStudentById(String id); public Boolean insertStudent(Student

Spring RPC 入门学习(3)-获取Student对象

Spring RPC传递对象. 1. 新建RPC接口:StudentInterface.java package com.cvicse.ump.rpc.interfaceDefine; import com.cvicse.ump.student.Student; public interface StudentInterface { public Student getStudentById(String id); } 2.新建RPC接口的实现类,StudentManager.java pack

1047. Student List for Course (25)

题目例如以下: Zhejiang University has 40000 students and provides 2500 courses. Now given the registered course list of each student, you are supposed to output the student name lists of all the courses. Input Specification: Each input file contains one te

java3- class student

1 package one; 2 import java.util.*; 3 import java.text.*; 4 class person{ 5 public String name; 6 public Date birthday; 7 public String sex ,province,city; 8 private static int count=0; 9 public person (String name,Date birthday, 10 String sex,Strin

Java基础知识强化之集合框架笔记60:Map集合之TreeMap(TreeMap&lt;Student,String&gt;)的案例

1. TreeMap(TreeMap<Student,String>)的案例 2. 案例代码: (1)Student.java: 1 package cn.itcast_04; 2 3 public class Student { 4 private String name; 5 private int age; 6 7 public Student() { 8 super(); 9 } 10 11 public Student(String name, int age) { 12 super

Java基础知识强化之集合框架笔记57:Map集合之HashMap集合(HashMap&lt;Student,String&gt;)的案例

1. HashMap集合(HashMap<Student,String>)的案例 HashMap<Student,String>键:Student      要求:如果两个对象的成员变量值都相同,则为同一个对象.值:String HashMap是最常用的Map集合,它的键值对在存储时要根据键的哈希码来确定值放在哪里. HashMap 中作为键的对象必须重写Object的hashCode()方法和equals()方法 2. 代码示例: (1)Student.java,如下: 1 pa