服务器之家

服务器之家 > 正文

java实现学生成绩录入系统

时间:2021-03-22 14:36     来源/作者:JokerLoveAllen

本文为大家分享了java实现学生成绩录入系统,供大家参考,具体内容如下

1.学生类,包括学生的姓名和各科成绩

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
public class score {
  public string name;
  public double englishgrade, mathgrade,phyicalgrade,
  chemicalgrade,biologicalgrade;
  score() {
 
  }
 
  public score(string name,double englishgrade,
      double mathgrade,double phyicalgrade,
      double chemicalgrade,double biologicalgrade){
    this.name = name;
    this.englishgrade = englishgrade;
    this.mathgrade = mathgrade; 
    this.phyicalgrade = phyicalgrade;
    this.chemicalgrade = chemicalgrade;
    this.biologicalgrade = biologicalgrade;
     
  }
 
}

2.对学生类进行设置,包括设置查找等

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package score;
 
public class scorezip {
  score[] s = new score[5];
 
  public void setdata(score name, int index) {//添加成绩类到成绩数组中
    s[index] = name;
  }
 
  public score[] getdata() { //返回学生数组
    return s;
  }
 
  public score serchdata(string name) { //查找学生各科成绩
    for (int index = 0; index < s.length; index++) {
      if (name !=null && s[index] != null )
        if (s[index].name.equals(name)){
          return s[index];
        }
     }
    return null;
  }
}

3.学生成绩录入及学生成绩清单

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package score;
 
import java.util.scanner;
 
 
public class scorezip2 {
  public static void main(string[] arr) {
    scanner sc = new scanner(system.in);
    scorezip sr = new scorezip();
    for (int i = 0; i < 5; i++) { //这里定义长度为五的学生成绩表
      system.out.println("输入学生姓名:");
      string name = sc.next();
      if (name.equals("n")) {
        break;
      }
      system.out.println("英语分数:");
      double english = sc.nextdouble();
      system.out.println("数学分数:");
      double math = sc.nextdouble();
      system.out.println("物理分数:");
      double physical = sc.nextdouble();
      system.out.println("化学分数:");
      double chemical = sc.nextdouble();
      system.out.println("生物分数:");
      double biology = sc.nextdouble();
       
       
      score s = new score(name, english,math,physical,chemical,biology);
      sr.setdata(s, i);
    }
    system.out.println("=========================================" +
        "学生成绩表======================================");
    system.out.println("姓名\t\t英语成绩\t\t数学成绩\t\t物理成绩\t\t化学成绩\t\t生物成绩");
    score[] b = sr.getdata();
    for (score s : b) {
      if (s == null) {
        break;
      }
      system.out.println(s.name + "\t\t" + s.englishgrade+"\t\t"+s.mathgrade
          +"\t\t"+s.phyicalgrade+"\t\t"+s.chemicalgrade+"\t\t"+s.biologicalgrade);
    }
    system.out.println("是否查找学生成绩? 是y 否n");
    string flag = sc.next();
    if(flag.equals("y")){
    system.out.println("输入要查找的学生名:");
    string name = sc.next();
    score s = sr.serchdata(name);
    if (s == null) {
      system.out.println("对不起,没有此学生名");
    } else {
      double mg = s.mathgrade;
      double eg = s.englishgrade;
      double pg = s.phyicalgrade;
      double cg= s.chemicalgrade;
      double bg = s.biologicalgrade;
      double submit = mg+eg+pg+cg+bg;
      system.out.println("要查找的学生为:" + name + "\n数学成绩为:" + mg
          + "\n英语成绩为:" + eg+ "\n物理成绩为:" + pg+ "\n化学成绩为:" + cg
          + "\n生物成绩为:" + bg+ "\n总成绩成绩为:" + submit);
       }
    }
  }
}

结果图:

java实现学生成绩录入系统

java实现学生成绩录入系统

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持服务器之家。

原文链接:http://blog.csdn.net/qq_34122768/article/details/52088940

相关文章

热门资讯

2020微信伤感网名听哭了 让对方看到心疼的伤感网名大全
2020微信伤感网名听哭了 让对方看到心疼的伤感网名大全 2019-12-26
yue是什么意思 网络流行语yue了是什么梗
yue是什么意思 网络流行语yue了是什么梗 2020-10-11
背刺什么意思 网络词语背刺是什么梗
背刺什么意思 网络词语背刺是什么梗 2020-05-22
Intellij idea2020永久破解,亲测可用!!!
Intellij idea2020永久破解,亲测可用!!! 2020-07-29
苹果12mini价格表官网报价 iPhone12mini全版本价格汇总
苹果12mini价格表官网报价 iPhone12mini全版本价格汇总 2020-11-13
返回顶部