题目:
编写个学生类(Students) ,包括姓名(name)、性别(sex)、学号(num) 、语文课(Chinese)、英语课(Engish)、 数学课(Math) 和平均值(avg),方法包括求三门课的平均分,要求输出小组各成员的相关信息。
程序:
public class student {
String name;
char sex;
int num;
int Chinese;
int English;
int avg;
int Math;
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
student p1 = new student();//声明students类对象p1
student p2 = new student();//声明students类对象p2
student p3 = new student();//声明students类对象p3
p1 . name = "高金华";
p1 . sex = 'n';
p1 . num =8;
p1 . Chinese = 100;
p1 . Math = 100;
p1 . English =100;
p1 .avg = 100;
p2 . name = "杨喜梅";
p2 . sex = 'v';
p2 . num =32;
p2 . Chinese = 100;
p2 . Math = 100;
p2 . English =100;
p2 .avg = 100;
p3 . name = "章燕";
p3 . sex = 'v';
p3 . num =33;
p3 . Chinese = 100;
p3 . Math = 100;
p3 . English =100;
p3 .avg = 100;
System.out.println("姓名 性别 学号 语文 数学 英语 平均值");//
System.out.println(""+p1.name+" " +p1.sex+ " "+p1.num+" " +p1.Chinese +" "+p1.Math+" " +p1.English+" " +p1.avg+"");//输出学生p1
System.out.println(""+p2.name+" " +p2.sex+ " "+p2.num+" " +p2.Chinese +" "+p2.Math+" " +p2.English+" " +p2.avg+"");//输出学生p2
System.out.println(""+p3.name+" " +p3.sex+ " "+p3.num+" " +p3.Chinese +" "+p3.Math+" " +p3.English+" " +p3.avg+"");//输出学生p3
}
}