如何用Java语言编写学生成绩管理系统
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了如何用Java语言编写学生成绩管理系统相关的知识,希望对你有一定的参考价值。
package student;import java.util.Scanner;
public class teststudent
public static void main(String args[])
System.out.println("************************学生成绩管理系统*********************");
System.out.println("请输入要管理的学生人数:");
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
studentMassage stum = new studentMassage(n);
int flag = 1;
while(flag == 1)
System.out.println("1.输入学生信息");
System.out.println("2.通过姓名查找学生信息");
System.out.println("3.显示全部学生信息");
System.out.println("4.退出系统");
int op = sc.nextInt();
switch(op)
case 1:stum.addStudent(n);
new Scanner(System.in).nextLine();
break;
case 2:
System.out.println("输入学生姓名:");
String name = sc.next();
stum.FindStudent(name);
new Scanner(System.in).nextLine();
break;
case 3:
stum.showallStudent();
new Scanner(System.in).nextLine();
break;
case 4:
flag = 0;
System.out.println("已退出系统!");
break;
default:
System.out.println("输入有误!");
new Scanner(System.in).nextLine();
class Date
int year;
int month;
int day;
/*public Date(int year,int month,int day)
this.year = year;
this.month = month;
this.day = day;
public Date()*/
public String showDate()
return year + "/"+ month+"/"+day;
class student
int id;
String name;
Date date;
float score;
public student()
id = 0;
name = null;
date = null;
score = 0f;
public void showStudent()
System.out.println( id + " " + name + " "+ " " + date.showDate()+" "+score);
class studentMassage
private student[] stu;
private int flag;
public studentMassage(int n)
flag = 0;
if(stu == null)
stu = new student[n];
for(int i =0;i<n;++i)
stu[i] = new student();
public void addStudent(int n)
flag = 1;
Scanner sc = new Scanner(System.in);
System.out.println("请输入"+n+"个学生信息");
for(int i = 0 ;i<stu.length;++i)
stu[i].date = new Date();
System.out.println("请输入第"+(i+1)+"个学生学号:");
stu[i].id = sc.nextInt();
System.out.println("请输入第"+(i+1)+"个学生姓名:");
stu[i].name = sc.next();
System.out.println("请输入第"+(i+1)+"个学生出生年份:");
stu[i].date.year = sc.nextInt();
System.out.println("请输入第"+(i+1)+"个学生出生月份:");
stu[i].date.month = sc.nextInt();
System.out.println("请输入第"+(i+1)+"个学生出生日期:");
stu[i].date.day = sc.nextInt();
//stu[i].date = new Date(year,month,day);
System.out.println("请输入第"+(i+1)+"个学生分数:");
stu[i].score = sc.nextFloat();
public void FindStudent(String sname)
student find = null;
if(flag != 0)
for(int i = 0;i<stu.length;++i)
if(sname.equals(stu[i].name))
find = stu[i];
if(find == null)
System.out.println("查无此人!");
else
find.showStudent();
else
System.out.println("没有输入学生信息!");
public void showallStudent()
System.out.println("所有学生的信息如下:");
System.out.println("学号 姓名 生日 分数");
for(int i = 0;i<stu.length;++i)
stu[i].showStudent();
参考技术A 设计数据库。编写代码,测试,完成
用JAVA编写一个学生类Student的程序
1. 定义一个学生类Student,包括:属性学号,姓名,性别,年龄,方法包括构造方法初始化变量;显示学号方法、显示姓名方法、显示性别方法、显示年龄方法、修改年龄方法。
2. 定义一个测试类StudentTest创建两个学生对象,John,Mark,通过新建对象传值初始化对象属性,分别显示两个学生的学号,性别,年龄,然后修改John的年龄并显示之。
public class Student
private String sno;
private String name;
private char sex;
private int age;
public Student()
// TODO Auto-generated constructor stub
public Student(String sno, String name, char sex, int age)
super();
this.sno = sno;
this.name = name;
this.sex = sex;
this.age = age;
public String getSno()
return sno;
public void setSno(String sno)
this.sno = sno;
public String getName()
return name;
public void setName(String name)
this.name = name;
public char getSex()
return sex;
public void setSex(char sex)
this.sex = sex;
public int getAge()
return age;
public void setAge(int age)
this.age = age;
package langs;
public class StudentTest
public static void main(String[] args)
Student john = new Student("s001","john",'男',24);
Student mark = new Student("s002","mark",'男',25);
System.out.println("john学号: " + john.getSno());
System.out.println("mark学号: " + mark.getSno());
System.out.println("john姓名: " + john.getName());
System.out.println("mark姓名: " + mark.getName());
System.out.println("john年龄: " + john.getAge());
System.out.println("mark年龄: " + mark.getAge());
john.setAge(26);
System.out.println("john年龄: " + john.getAge());
public class Student
private String num;//学号
private String name;//姓名
private String sex;//性别
private int age;//年龄
public Student(String num,String name,String sex,int age)
this.num = num;
this.name = name;
this.sex = sex;
this.age = age;
public String getNum()
return num;
public void setNum(String num)
this.num = num;
public String getName()
return name;
public void setName(String name)
this.name = name;
public String getSex()
return sex;
public void setSex(String sex)
this.sex = sex;
public int getAge()
return age;
public void setAge(int age)
this.age = age;
测试类:
public class StudentTest
public static void main(String[] args)
Student John = new Student("0000026", "John", "男", 18);//John
Student Mark = new Student("0000027", "Mark", "男", 20);//Mark
System.out.println(John.toString());//显示是输出?
System.out.println(Mark.toString());
John.setAge(22);//修改John年龄
System.out.println("修改后的John:"+John.toString());
参考技术B 楼主这个太简单了,看看书自己就可以做出来,我在想要不要告诉你,这样会不会对你学习不太好吧。。。 参考技术C 这个是你们老师布置的作业吧。。。。本回答被提问者采纳
以上是关于如何用Java语言编写学生成绩管理系统的主要内容,如果未能解决你的问题,请参考以下文章