5.1 “学生”类:
² 类名:Student
² 属性:姓名、性别、年龄、学号、5门课程的成绩
² 方法1:在控制台输出各个属性的值、
² 方法2:计算平均成绩
² 方法3:输出各个属性的值和平均成绩
public class student {
String name; String sex; int age; String number; String score; int ascore; public static void main(String[] args){ student a = new student(); a.ascore = (100+99+98+97+96)/5; a.name = "杨浩亮"; a.sex = "男"; a.age = 20; a.number = "201801420253"; a.score = "语文:100 英语:99 数学:98 物理:97 化学:96"; System.out.println("名字: "+a.name+" 性别: "+a.sex+" 年龄: "+a.age+" 学号: "+a.number+" 分数: "+a.score+" 平均分: "+(int)a.ascore); } }