简易学生成绩管理管理系统(java描述)
没正式学过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中编译:
运行结果:
如有不对,欢迎批评指针~
少一些功利主义的追求,多一些不为什么的坚持!