题目:

      编写个学生类(Students) ,包括姓名(name)、性别(sex)、学号(num) 、语文课(Chinese)、英语课(Engish)、 数学课(Math) 和平均值(avg),方法包括求三门课的平均分,要求输出小组各成员的相关信息。


源代码:

package com.soft.ght;

//学生类
public class Students {
/**
* @param args
*/
@SuppressWarnings("unused")
String name;
   String sex;
  int num;
   int Chinese;
   int English;
   int Math;
   int avg;
public static void main(String[] args) {
// TODO Auto-generated method stub
Students  c1 = new Students ();//声明并实例化Students 类对象c1
Students  c2 = new Students ();//声明并实例化Students 类对象c2
Students  c3 = new Students ();//声明并实例化Students 类对象c3
Students  c4 = new Students ();//声明并实例化Students 类对象c4
c1.name="邓雪芳";
c1. sex="女";
c1.num=162507207;
c1.Chinese=100;
c1.English=100;
c1.Math=100;
c1.avg=100;
c2.name="高金华";
c2. sex="男";
c2.num=162507208;
c2.Chinese=100;
c2.English=100;
c2.Math=100;
c2.avg=100;
c3.name="杨喜梅";
c3. sex="女";
c3.num=162507232;
c3.Chinese=100;
c3.English=100;
c3.Math=100;
c3.avg=100;
c4.name="章燕";
c4. sex="女";
c4.num=162507233;
c4.Chinese=99;
c4.English=99;
c4.Math=99;
c4.avg=99;
System.out.println("姓   名"+"     性别   "+"       学号    "+"  语文课  "+" 英语课  "+" 数学课   "+" 均值 ");
System.out.println(""+c1.name+"     "+c1. sex+"      "+c1.num+"       "+c1.Chinese+"      "+c1.English+"        "+c1.Math+"        "+c1.avg);
System.out.println(""+c2.name+"     "+c2. sex+"      "+c2.num+"       "+c2.Chinese+"      "+c2.English+"        "+c2.Math+"        "+c2.avg);
System.out.println(""+c3.name+"     "+c3. sex+"      "+c3.num+"       "+c3.Chinese+"      "+c3.English+"        "+c3.Math+"        "+c3.avg);

System.out.println(" "+c4.name+"       "+c4. sex+"      "+c4.num+"        "+c4.Chinese+"         "+c4.English+"          "+c4.Math+"          "+c4.avg);

//输出学生信息

}


}

课后作业之学生类

相关文章:

  • 2021-12-16
  • 2022-12-23
  • 2021-09-16
猜你喜欢
  • 2021-12-01
  • 2021-10-05
  • 2022-02-02
  • 2022-12-23
  • 2022-01-13
  • 2021-07-12
  • 2021-12-20
相关资源
相似解决方案