簡易學產生績管理管理系統(java描述)

來源:互聯網
上載者:User

標籤:src   util   外部   技術   基本文法   ann   isp   許可權   pre   

沒正式學過java,但是系統學過C++後,初略的看了下java的基本文法,於是我就嘗試著用java來寫個簡單的學生管理系統,功能不齊全,以後有空再補充吧。

寫的時候定義了不同的包名字,如jeaven1 , jeaven2 , jeaven3

先上Student類:

 1 package jeaven1; 2 import java.io.*; 3  4 public class Student 5 { 6     private String name; 7     private String id; 8     private String sex; 9     private int age;10     private double grade;11     public Student next; //public給外部直接存取next的許可權12     13     public Student(String _name,String _id,String _sex,int _age,double _grade)14     {15         this.name = _name;16         this.id = _id;17         this.sex = _sex;18         this.age = _age;19         this.grade = _grade;20         this.next = null;21     }22     23     public Student()24     {25         this.name = "null";26         this.id = "null";27         this.sex = "null";28         this.age = 0;29         this.grade = 0;30         this.next = null;31     }32     33     public void show()34     {35         System.out.println("名字:"+name+" "+"學號:"+id+" "+"性別:"+sex+" "+"年齡:"+age+" "+"成績:"+grade);36     }37 }38 

再上stulist類

 1 package jeaven2; 2 import java.io.*; 3 import jeaven1.Student; 4 import java.util.Scanner; 5  6 public class stulist 7 { 8     private Student head; //前端節點 9     private int num; //儲存學生資訊個數10     public stulist()11     {12         head = new Student();13         num = 0;14     }15     16     public void Insert()17     {18         String _name,_id,_sex;19         int _age;20         double _grade;21         Scanner in = new Scanner(System.in);22         System.out.printf("請輸入學生姓名: ");23         _name = in.nextLine();24         System.out.printf("請輸入學生學號: ");25         _id = in.nextLine();26         System.out.printf("請輸入學生性別: ");27         _sex = in.nextLine();28         System.out.printf("請輸入學生年齡: ");29         _age = in.nextInt();30         System.out.printf("請輸入學產生績: ");31         _grade = in.nextDouble();32         System.out.printf("\n");33         Student newstu = new Student(_name,_id,_sex,_age,_grade);34         Student p = head;35         while(p.next != null)36         {37             p = p.next;38         }39         p.next = newstu;40         newstu.next = null;41         num ++;42     }43     44     public void display()45     {46         Student p = head.next;47         while(p != null)48         {49             p.show();50             p = p.next;51         }52         if(num == 0)53             System.out.println("此時沒有任何學生的資訊...");54     }55 }

再上main類

 1 package jeaven3; 2 import jeaven1.Student; 3 import jeaven2.stulist; 4  5 public class main 6 { 7     public static void main(String[] args) 8     { 9         stulist list = new stulist();10         list.Insert();11         list.Insert();12         list.display();13     }14 }

在windows下cmd中編譯:

運行結果:

 

如有不對,歡迎批評指標~

 

簡易學產生績管理管理系統(java描述)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.