Did not formally learn Java, but the system has learned C + +, the initial look at the basic syntax of Java, so I tried to write a simple student management system with Java, the function is not complete, after the empty to add it.
When writing defines different package names, such as Jeaven1, Jeaven2, Jeaven3
First on the student class:
1 PackageJeaven1;2 ImportJava.io.*;3 4 Public classStudent5 {6 PrivateString name;7 PrivateString ID;8 PrivateString sex;9 Private intAge ;Ten Private Doublegrade; One PublicStudent Next;//Public permission to directly access next to external A - PublicStudent (String _name,string _id,string _sex,int_age,Double_grade) - { the This. Name =_name; - This. ID =_id; - This. Sex =_sex; - This. Age =_age; + This. grade =_grade; - This. Next =NULL; + } A at PublicStudent () - { - This. Name = "NULL"; - This. ID = "NULL"; - This. Sex = "null"; - This. Age = 0; in This. grade = 0; - This. Next =NULL; to } + - Public voidShow () the { *System.out.println ("Name:" +name+ "" + "study Number:" +id+ "" + "Gender:" +sex+ "" + "Age:" +age+ "" + "Score:" +grade); $ }Panax Notoginseng } -
Then on the Stulist class
1 PackageJeaven2;2 ImportJava.io.*;3 ImportJeaven1. Student;4 ImportJava.util.Scanner;5 6 Public classstulist7 {8 PrivateStudent Head;//head Node9 Private intNum//number of student information storedTen Publicstulist () One { AHead =NewStudent (); -num = 0; - } the - Public voidInsert () - { - String _name,_id,_sex; + int_age; - Double_grade; +Scanner in =NewScanner (system.in); ASystem.out.printf ("Please enter student's name:"); at_name =in.nextline (); -System.out.printf ("Please enter student number:"); -_id =in.nextline (); -System.out.printf ("Please enter student Gender:"); -_sex =in.nextline (); -System.out.printf ("Please enter Student Age:")); in_age =in.nextint (); -System.out.printf ("Please enter student results:"); to_grade =in.nextdouble (); +System.out.printf ("\ n"); -Student Newstu =NewStudent (_name,_id,_sex,_age,_grade); theStudent p =head; * while(P.next! =NULL) $ {Panax Notoginsengp =P.next; - } theP.next =Newstu; +Newstu.next =NULL; ANum + +; the } + - Public voiddisplay () $ { $Student p =Head.next; - while(P! =NULL) - { the p.show (); -p =P.next;Wuyi } the if(num = = 0) -System.out.println ("No student information at this time ..."); Wu } -}
And then the main class
1 PackageJeaven3;2 ImportJeaven1. Student;3 Importjeaven2.stulist;4 5 Public classMain6 {7 Public Static voidMain (string[] args)8 {9Stulist list =Newstulist ();Ten list. Insert (); One list. Insert (); A List.display (); - } -}
Compile in Windows cmd:
Operation Result:
If not, welcome to criticize the pointer ~
Simple Student performance Management system (Java description)