1条回答 默认 最新
- 笑看烟雨红尘 2019-10-08 01:05关注
public class Student {
private String name, xuehao;
private int chengji;public Student(String name, String xuehao, int chengji) { this.name = name; this.xuehao = xuehao; this.chengji = chengji; } public String 计算学生成绩方法() { String cj = null; if(chengji >= 90) { cj = "A"; } else if(chengji >= 80) { cj = "B"; } else if(chengji >= 70) { cj = "C"; } else if(chengji >= 60) { cj = "D"; } else { cj = "E"; } return "姓名:" + name + ",学号:" + xuehao + ",成绩:" + cj; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getXuehao() { return xuehao; } public void setXuehao(String xuehao) { this.xuehao = xuehao; } public int getChengji() { return chengji; } public void setChengji(int chengji) { this.chengji = chengji; }
}
public class Students {
private Student[] students = new Student[100];
private static int amount;public Students(int amount) { Students.amount = amount; } public int avergeScore() { int sum = 0; for (Student student : students) { sum += student.getChengji(); } return sum / amount; } public int highestScore() { int max = 0, chengji = 0; for (Student student : students) { chengji = student.getChengji(); if(chengji > max) { max = chengji; } } return max; } public void newStudent(Student student) { students[students.length] = student; }
}
解决 无用评论 打赏 举报
悬赏问题
- ¥15 python怎么在已有视频文件后添加新帧
- ¥20 虚幻UE引擎如何让多个同一个蓝图的NPC执行一样的动画,
- ¥15 fluent里模拟降膜反应的UDF编写
- ¥15 MYSQL 多表拼接link
- ¥15 关于某款2.13寸墨水屏的问题
- ¥15 obsidian的中文层级自动编号
- ¥15 同一个网口一个电脑连接有网,另一个电脑连接没网
- ¥15 神经网络模型一直不能上GPU
- ¥15 pyqt怎么把滑块和输入框相互绑定,求解决!
- ¥20 wpf datagrid单元闪烁效果失灵