JAVA2222



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

/*学生类,显示出小组成员的姓名、性别、学号 、语文课、英语课、 数学课并计算出每人的平均值*/
public class Students {
        String name;      //定义姓名,性别, 学号, 语文,英语,数学 ,平均值
char sex;                                                                                                              
int num;                                                                                                               
int Chinese;                                                                                                           
int Enghlish;                                                                                                          
int  Math;                                                                                                             
double avg;                                                                                                            


public static void main(String[] args) {                                                                               


Students d1 =new Students ();//声明并实例化students类对象d1                                                                                
Students d2 =new Students();//声明并实例化students类对象d2                                                                                 
Students  d3 =new Students();//声明并实例化students类对象d3                                                                                
Students d4 =new Students();//声明并实例化students类对象d4                                                                                 
d1.name = "曹桂";                                                                                                         
d1.sex ='女';                                                                                                            
d1.num = 162507201;                                                                                                     
d1.Chinese =95;                                                                                                         
d1. Enghlish=83;                                                                                                        
d1. Math =98;                                                                                                           
d1. avg = 88;                                                                                                           
d2.name = "胡媛媛";                                                                                                        
d2.sex ='女';                                                                                                            
d2.num = 162507211;                                                                                                     
d2.Chinese =92;                                                                                                         
d2. Enghlish=88;                                                                                                        
d2. Math =86;                                                                                                           
d2. avg = 80;                                                                                                           
d3.name = "韦淑敏";                                                                                                        
d3.sex ='女';                                                                                                            
d3.num= 162507228;                                                                                                      
d3.Chinese =90;                                                                                                         
d3. Enghlish=85;                                                                                                        
d3. Math =79;                                                                                                           
d3. avg = 89;                                                                                                           
d4.name = "刘玉强";                                                                                                        
d4.sex ='男';                                                                                                            
d4.num= 162507219;                                                                                                      
d4.Chinese =97;                                                                                                         
d4. Enghlish=80;                                                                                                        
d4. Math =87;                                                                                                           
d4. avg = 89;                                                                                                           
System.out.println(" 姓名 "+" 性别"+"     学号   "+"        语文 "+"      英语 "+"      数学 "+"    平均值 ");          //输出 students类对象d1的姓名,性别, 学号, 语文,英语,数学 ,平均值              
System.out.println(""+d1.name+ "  "+d1.sex+"   "+d1.num+"  "+d1.Chinese+"  "+d1. Enghlish+"  "+d1. Math+"  "+d1. avg); 
System.out.println(""+d2.name+ "  "+d2.sex+"   "+d2.num+"  "+d2.Chinese+"  "+d2. Enghlish+"  "+d2. Math+"  "+d2. avg);  
System.out.println(" "+d3.name+ "    "+d3.sex+"   "+d3.num+"  "+d3.Chinese+"  "+d3. Enghlish+"  "+d3. Math+"  "+d3. avg);
System.out.println(""+d4.name+ "  "+d4.sex+"   "+d4.num+"  "+d4.Chinese+"  "+d4. Enghlish+"  "+d4. Math+"  "+d4. avg);  


}                                                                                                                      






}       
                                                                                                             
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值