java阶段项目:学生成绩管理系统(面向对象)
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
Java 学生信息管理系统(面向对象)一:效果如下:
二:具体实现代码如下:Student类Student .java
public class Student {
private int id;
private String name;
private int age;
private int java;
private int csharp;
private int html;
private int sql;
private int sum;
private int avg;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) { = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public int getJava() {
return java;
}
public void setJava(int java) { this.java = java;
}
public int getCsharp() {
return csharp;
}
public void setCsharp(int csharp) { this.csharp = csharp;
}
public int getHtml() {
return html;
}
public void setHtml(int html) { this.html = html;
}
public int getSql() {
return sql;
}
public void setSql(int sql) {
this.sql = sql;
}
public int getSum() {
return sum;
}
public void setSum() {
this.sum = this.java+this.csharp+this.html+this.sql;
}
public int getAvg() {
return avg;
}
public void setAvg() {
this.avg = this.sum/4;
}
public String toString()
{
String
msg="\t"+this.id+"\t"++"\t"+this.age+"\t"+this.java
+"\t"+this.csharp+"\t"+this.html+"\t"+this.sql+"\t"+this.sum+"\t" +this.avg;
return msg;
}
}
学生信息管理类StudentAdmin.java
import java.util.Scanner;
public class StudentAdmin {
String msg="\t编号\t姓名\t年龄\tjava\tcsharp\thtml\tsql\t总分\t平均分";
//打印现有学生
public void print(Student [] stu){
System.out.println(msg);
for(int i=0;i { if(stu[i]!=null){ System.out.println(stu[i]); } } } //添加学生 public void addStudent(String name,int age,Student [] stu) { Student student=new Student(); student.setName(name); student.setAge(age); int i=this.getIndex(stu); if(i==9999) { System.out.println("数组已经容纳最大量,不能再接受"); } else{ student.setId(i); } stu[i]=student; } //获取编号 public int getIndex(Student [] stu) { for(int i=0;i { if(stu[i]==null) { return i; } } return 9999; } //根据学生编号查找学生 public void selectStudent(int id,Student [] stu) { System.out.println(msg); for(int i=0;i { if(stu[i]!=null) { if(this.exits(id, stu[i])){ if(stu[i].getId()==id) { System.out.println(stu[i]); return; } }