Using list in Java to implement a simple student management system

Source: Internet
Author: User
Tags sca

As a Java programmer, regardless of beginner or great God, student management system is a good example, beginners with arrays, lists and so on to write a simple student management system, the great God is to use the swing+ database to do the interface of the student management system, nonsense not much to say, Today, I use list to implement the student management system.

Student management system mainly for students, we first write the student object.

Package Testproject;public class Student {    String name;    String age;    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;    }}

Here are some * get and set methods (more lazy to write two casually)

    System.out.println ("Welcome to Student management System");    System.out.println ("" 1 "registration");    System.out.println ("" 2 "View");    System.out.println ("3" and "Modified");    System.out.println ("" 4 "delete");    System.out.print ("Please select your action:");

The following is the main page of the implementation of the various functions crap, don't say much about code.

Package Testproject;import Java.util.arraylist;import Java.util.list;import Java.util.scanner;public class    Testdemo02 {/** * operator interface */static Scanner SCA = new Scanner (system.in);    static list<student> L = new arraylist<student> ();    static student C = new student ();    Static Boolean Stu = true;        public static void Main (string[] args) {System.out.println ("Welcome to Student management System");        System.out.println ("" 1 "registration");        System.out.println ("" 2 "View");        System.out.println ("3" and "Modified");        System.out.println ("" 4 "delete");        System.out.print ("Please select your action:");            while (Stu) {String stus = Sca.nextline ();                Switch (stus) {case "1": Add ();            Break                Case "2": sel ();            Break                Case "3": Set ();            Break                Case "4": Del ();            Break }}}/*** * Add function */Static void Add () {while (Stu) {System.out.println ("Please enter student name");            C.setname (Sca.nextline ());            System.out.println ("Please enter student age");            C.setage (Sca.nextline ());            System.out.println ("add success");            L.add (c);        Break }}/** * Query function * * * static void Sel () {for (student c:l) {System.out.println ("Name:" +c.        GetName () + "" + "Age:" +c.getage ());        }}/** * Delete function */static void Del () {System.out.println ("Please enter name to delete");        String names = Sca.nextline (); for (int i=0;i<l.size (); i++) {if (Names.equals (L.get (i). GetName ())) {System.out.println ("Find student                deleting ");                L.remove (i);            System.out.println ("delete succeeded");            }else {System.out.println ("deletion failed to find student");        }}}/** * Modify function */static void set () {System.out.println ("Please enter the name of the student to be modified"); String names = Sca.nextline(); for (int i=0;i<l.size (); i++) {if (Names.equals (L.get (i). GetName ())) {System.out.println ("Discover student                Being modified ");                System.out.println ("Please enter the modified name");                String name = Sca.nextline ();                L.get (i). SetName (name);                System.out.println ("Please enter the Modified age");                String age = Sca.nextline ();                L.get (i). Setage (age);            SYSTEM.OUT.PRINTLN ("modified successfully");            }else{System.out.println ("Student not Found" in the "Modification failed"); }        }    }}

Is it very easy to see these? Beginners are a good fit to get practiced hand.
A simple student management system is complete is not very simple?

Related articles:

Student Performance Management System

How the shell realizes the student achievement management system

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.