学生成绩管理
Posted 芽籽1997
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了学生成绩管理相关的知识,希望对你有一定的参考价值。
public
class
Grade {
private
:double
english;
double
math;
double
Chinese;
public:
Grade(
double
english,
double
math,
double
Chinese
)
{
this
.english = english;
this
.math = math;
this
.Chinese
= Chinese
;
}
double
sum()
{
return
this.english+this.math+this.Chinese
;
}
void
displayTotal()
{
System.out.println(sum());
}
double
average()
{
return
total()/
3
;
}
void
displayAverage()
{
System.out.println(average());
}
double
getEnglish()
{
return
english;
}
void
setEnglish(
double
english)
{
this
.english = english;
}
double
getMath()
{
return
math;
}
void
setMath(
double
math)
{
this
.math = math;
}
public
double
getChinese
()
{
return
Chinese
;
}
public
void
setChinese
(
double
Chinese
) {
this.
Chinese
= Chinese
;
}
}
public
class
Student {
String name;
Grade grade;
public
Student(String name, Grade grade) {
this
.name = name;
this
.grade = grade;
}
public
static
void
main(String[] args)
{
Student s =
new
Student(
"Cici"
,
new
Grade(
70
,
80
,
90
));
s.grade.printAverage();
s.grade.printTotal();
}
}
以上是关于学生成绩管理的主要内容,如果未能解决你的问题,请参考以下文章