最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Java實(shí)現(xiàn)簡(jiǎn)單學(xué)生信息管理系統(tǒng)

 更新時(shí)間:2021年09月14日 16:05:37   作者:悠檸  
這篇文章主要為大家詳細(xì)介紹了Java實(shí)現(xiàn)簡(jiǎn)單學(xué)生信息管理系統(tǒng),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

最近在學(xué)習(xí)Java,所以寫了個(gè)學(xué)生信息管理系統(tǒng),話不多說(shuō),上代碼。

Student.java:

package com.mumu;

public class Student {  //定義學(xué)生類
    private String name;
    private String age;
    private String id;
    private String room_num;
    private int math;
    private int english;
    private int physic;

    public Student() {//無(wú)參構(gòu)造方法
    }

    public Student(String name, String age, String id, String room_num, int math, int english, int physic) {
        this.name = name;
        this.age = age;
        this.id = id;
        this.room_num = room_num;
        this.math = math;
        this.english = english;
        this.physic = physic;
    }

//Alt+ INSERT鍵,可自動(dòng)生成構(gòu)造方法
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAge() {
        return age;
    }

    public void setAge(String age) {
        this.age = age;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getRoom_num() {
        return room_num;
    }

    public void setRoom_num(String room_num) {
        this.room_num = room_num;
    }

    public int getMath() {
        return math;
    }

    public int getEnglish() {
        return english;
    }

    public int getPhysic() {
        return physic;
    }

    public void setMath(int math) {
        this.math = math;
    }

    public void setEnglish(int english) {
        this.english = english;
    }

    public void setPhysic(int physic) {
        this.physic = physic;
    }
}

StudentManager .java:

package com.mumu;

import java.util.ArrayList;
import java.util.Scanner;

public class StudentManager {
    public static void main(String[] args) {

    ArrayList<Student> array=new ArrayList<>();
    menu(array);
    }
    public static void menu(ArrayList<Student> array)//菜單
    {
        while(true)
        {
            System.out.println("^^^^^^^^welcom to my System^^^^^^^^");
            System.out.println("please input your choice");
            System.out.println("1.add students' information");
            System.out.println("2.remove students' information");
            System.out.println("3.revise students' information");
            System.out.println("4.look over students' information");
            System.out.println("5.find  students' information");
            System.out.println("6.quit the system");
            Scanner sc=new Scanner(System.in);
            String choice =sc.nextLine();
            switch(choice)
            {
                case "1":
                    adding(array);
                    break;
                case "2":
                    removing(array);
                    break;
                case "3":
                    revising(array);
                    break;
                case "4":
                    look_over(array);
                    break;
                case "5":
                    serching(array);
                case "6":
                    quiting();
                    break;
                default:
                    System.out.println("error!");
                    System.exit(0);
            }
        }

    }

    public static void adding(ArrayList<Student> array)//添加學(xué)生信息
    {//錄入的學(xué)生數(shù)據(jù)錄入給成員變量
        System.out.println("please input student's id");
        Scanner sc=new Scanner(System.in);
        String stu_num=sc.nextLine();
        if(is_used(array,stu_num)==false)
        {
            System.out.println("please input student's name");
            String stu_name=sc.nextLine();
            System.out.println("please input student's age");
            String stu_age=sc.nextLine();
            System.out.println("please input student's room number");
            String stu_addr=sc.nextLine();
            System.out.println("do you want to add student's grade?yes/no");
            //創(chuàng)建學(xué)生對(duì)象
            Student st=new Student();
            st.setAge(stu_age);
            st.setId(stu_num);
            st.setName(stu_name);
            st.setRoom_num(stu_addr);
            //添加學(xué)生成績(jī)
            String cho=sc.nextLine();
            if(cho=="yes")
            {
                System.out.println("please input student's math grade");
                int stu_math=sc.nextInt();
                System.out.println("please input student's english grade");
                int stu_english= sc.nextInt();
                System.out.println("please input student's physic grade");
                int stu_physic= sc.nextInt();
                st.setMath(stu_math);
                st.setEnglish(stu_english);
                st.setPhysic(stu_physic);
            }
            //將學(xué)生對(duì)象添加到集合中
            array.add(st);
            System.out.println("add successfully");
        }
        else
        {
            System.out.println("you are already input information of this student");
        }

    }
    public static void removing(ArrayList<Student> array)//刪除學(xué)生信息
    {
    Scanner sc=new Scanner(System.in);
        System.out.println("please input student's number");
        String stu_num=sc.nextLine();
        for(int i=0;i<array.size();i++)
        {
            Student st=array.get(i);
            if(st.getId().equals(stu_num))
            {
                array.remove(i);
                break;
            }
            else
            {
                System.out.println("there is no information of that student");
            }
        }
        System.out.println("remove successfully");
    }
    public static void revising(ArrayList<Student> array)//修改學(xué)生信息
    {
        Scanner sc=new Scanner(System.in);
        System.out.println("please input stubent's id");
        String stu_num=sc.nextLine();
        System.out.println("please input student's new name");
        String stu_name=sc.nextLine();
        System.out.println("please input student's new  id");
        String stu_id=sc.nextLine();
        System.out.println("please input student's new age");
        String stu_age=sc.nextLine();
        System.out.println("please input student's new room_number");
        String stu_add=sc.nextLine();
        System.out.println("do you want to revise student's grade?yes/no");
        //創(chuàng)建學(xué)生對(duì)象
        Student st1=new Student();
        st1.setRoom_num(stu_add);
        st1.setName(stu_name);
        st1.setId(stu_id);
        st1.setAge(stu_age);
        String cho= sc.nextLine();
        if(cho=="yes")
        {
            System.out.println("please input student's new math grade");
            int stu_math=sc.nextInt();
            System.out.println("please input student's new english grade");
            int stu_english=sc.nextInt();
            System.out.println("please input student's new physic grade");
            int stu_physic=sc.nextInt();
            st1.setEnglish(stu_english);
            st1.setMath(stu_math);
            st1.setPhysic(stu_physic);
        }
        for(int i=0;i< array.size();i++)
        {
            Student st2=array.get(i);
            if(st2.getId().equals(stu_num))//判斷輸入的學(xué)號(hào)是否在array里面
            {
                array.set(i,st1);
                break;
            }
            else
            {
                System.out.println("there is no information of that student");
            }
        }
        System.out.println("revise successfully");
    }
    public static void look_over(ArrayList<Student> array)//查看所有學(xué)生信息
    {
        if(array.size()==0)//先判斷集合是否為空
        {
            System.out.println("there is no information,please input information firstly");
        }
        else
        {
            System.out.println("number\tname\tage\troom_number\tmath_grade\tenglish_grade\tphysic_grade");
            for(int i=0;i<array.size();i++)
            {
                Student st=array.get(i);
                System.out.println(st.getId()+"\t"+st.getName()+"\t"+st.getAge()+"\t"+st.getRoom_num()+"\t"
                        +st.getMath()+"\t"+st.getEnglish()+"\t"+st.getPhysic());
            }

        }

    }
    public static void quiting() //退出系統(tǒng)
    {
        System.exit(0);
    }

    public static boolean is_used(ArrayList<Student> array,String sid)//判斷學(xué)號(hào)是否重復(fù)
    {
        boolean temp=false;
        for(int i=0;i< array.size();i++)
        {
            Student st=array.get(i);
            if(st.getId().equals(sid))
            {
                temp=true;
                break;
            }
        }
        return temp;
    }
    public static void serching(ArrayList<Student> array)//通過(guò)學(xué)號(hào)查找
  {
      System.out.println("please input id of the student you want to find");
      Scanner sc=new Scanner(System.in);
      String stu_num=sc.nextLine();
      for(int i=0;i< array.size();i++)
      {
          Student st= array.get(i);
          if(st.getId().equals(stu_num))
          {
              System.out.println(st.getId()+"\t"+st.getName()+"\t"+st.getAge()+"\t"+st.getRoom_num()+"\t"
                      +st.getMath()+"\t"+st.getEnglish()+"\t"+st.getPhysic());
          }
          else
          {
              System.out.println("there is no information of that student");
          }
      }
  }
}

代碼是用IDEA寫的,因?yàn)槭浅鯇W(xué)者,功能相對(duì)簡(jiǎn)單,如有問(wèn)題歡迎指正哦。

更多學(xué)習(xí)資料請(qǐng)關(guān)注專題《管理系統(tǒng)開發(fā)》。

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • RestTemplate Get請(qǐng)求實(shí)現(xiàn)bean參數(shù)傳遞詳解

    RestTemplate Get請(qǐng)求實(shí)現(xiàn)bean參數(shù)傳遞詳解

    RestTemplate 是從 Spring3.0 開始支持的一個(gè) HTTP 請(qǐng)求工具,也有的稱之為網(wǎng)絡(luò)框架,說(shuō)白了就是Java版本的一個(gè)postman,這篇文章主要介紹了詳解RestTemplate 用法,需要的朋友可以參考下
    2022-11-11
  • 詳解如何在Elasticsearch中搜索空值

    詳解如何在Elasticsearch中搜索空值

    這篇文章主要為大家介紹了如何在Elasticsearch中搜索空值的方法示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-01-01
  • java實(shí)現(xiàn)簡(jiǎn)單的彈球游戲

    java實(shí)現(xiàn)簡(jiǎn)單的彈球游戲

    這篇文章主要為大家詳細(xì)介紹了java實(shí)現(xiàn)簡(jiǎn)單的彈球游戲,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-08-08
  • 解決mybatis使用char類型字段查詢oracle數(shù)據(jù)庫(kù)時(shí)結(jié)果返回null問(wèn)題

    解決mybatis使用char類型字段查詢oracle數(shù)據(jù)庫(kù)時(shí)結(jié)果返回null問(wèn)題

    這篇文章主要介紹了mybatis使用char類型字段查詢oracle數(shù)據(jù)庫(kù)時(shí)結(jié)果返回null問(wèn)題的解決方法,本文給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2018-06-06
  • java對(duì)同一個(gè)文件進(jìn)行讀寫操作方法

    java對(duì)同一個(gè)文件進(jìn)行讀寫操作方法

    在本篇文章里我們給大家詳細(xì)講述了java對(duì)同一個(gè)文件進(jìn)行讀寫操作的方法和知識(shí)點(diǎn),需要的朋友們可以參考學(xué)習(xí)下。
    2018-10-10
  • Java中的動(dòng)態(tài)綁定機(jī)制

    Java中的動(dòng)態(tài)綁定機(jī)制

    這篇文章主要介紹了Java中的動(dòng)態(tài)綁定機(jī)制,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-06-06
  • 詳解spring注解式參數(shù)校驗(yàn)

    詳解spring注解式參數(shù)校驗(yàn)

    本篇文章主要介紹了詳解spring注解式參數(shù)校驗(yàn),小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2017-06-06
  • Java給PDF加水印并合并多個(gè)文件

    Java給PDF加水印并合并多個(gè)文件

    大家好,本篇文章主要講的是Java給PDF加水印并合并多個(gè)文件,感興趣的同學(xué)趕快來(lái)看一看吧,對(duì)你有幫助的話記得收藏一下
    2022-02-02
  • 詳解SpringBoot迭代發(fā)布JAR瘦身配置

    詳解SpringBoot迭代發(fā)布JAR瘦身配置

    這篇文章主要介紹了詳解SpringBoot迭代發(fā)布JAR瘦身配置,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2018-08-08
  • Java輸入/輸出流體系詳解

    Java輸入/輸出流體系詳解

    這篇文章主要介紹了Java輸入/輸出流體系詳解,涉及字節(jié)流和字符流,輸入輸出體系,轉(zhuǎn)換流,以及文件的讀寫等相關(guān)內(nèi)容,具有一定參考價(jià)值,需要的朋友可以了解下。
    2017-11-11

最新評(píng)論

九龙城区| 偏关县| 米脂县| 祁连县| 仁怀市| 肃南| 石城县| 靖州| 卢湾区| 定远县| 铅山县| 永城市| 清徐县| 文安县| 林周县| 瓮安县| 衡东县| 兴隆县| 嘉义县| 揭阳市| 英超| 三原县| 龙川县| 根河市| 六盘水市| 余江县| 汉沽区| 宁津县| 方山县| 京山县| 台东县| 安乡县| 三原县| 延长县| 彭阳县| 繁峙县| 丰城市| 宝兴县| 广汉市| 余干县| 呼和浩特市|