Java--学生类(成员变量,成员方法输出学生信息和平均成绩)

package gh;
class xs{
    //成员变量
    int xh;
 String xm;
    int sx;
    int yw;
    int yy;
    
    //构造方法
    xs(int xh1,String xm1,int sx1,int yw1,int yy1)
    {
        xh=xh1;
        xm=xm1;
        sx=sx1;
        yw=yw1;
        yy=yy1;
    }
    
    //成员方法
    int ave()
    {
        int result;
        result = (sx+yw+yy)/3;
        return result;
                
    }
}
public class xsgj {

    public static void main(String[] args) {
        // TODO Auto-generated method stub

        int avescore;
        xs xs1 = new xs(119509228,"周月",100,90,89);
        avescore=xs1.ave();
        System.out.println("平均成绩"+avescore);
    }

}

 

posted @ 2020-12-21 23:58  zhou小月  阅读(653)  评论(0编辑  收藏  举报