用java写程序,定义一个student类,包含的内容如下。成员变量:学号、姓名、性别、班干部否、数学、语文、
3个回答
展开全部
public class Student {
/**
* @param args
*/
boolean master; //定义成员变量
int num;
String name,sex;
double math,chinese,english,score=0.0,average=0.0;
Student(int num,String name, String sex, boolean ma, double math, double chinese, double english ){ //构造方法
this.num = num;
this.name = name;
this.sex = sex;
this.master = ma;
this.math = math;
this.chinese = chinese;
this.english = english;
}
void score(){ //计算总分方法
score= math+chinese+english;
System.out.println(score);
}
void ave(){ //计算平均分方法
average = score/3;
System.out.println(average);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
Student s = new Student(101,"kit","male",true,90.0,90.0,90.0); //创建对象
s.score(); //调用方法
s.ave();
}
}
/**
* @param args
*/
boolean master; //定义成员变量
int num;
String name,sex;
double math,chinese,english,score=0.0,average=0.0;
Student(int num,String name, String sex, boolean ma, double math, double chinese, double english ){ //构造方法
this.num = num;
this.name = name;
this.sex = sex;
this.master = ma;
this.math = math;
this.chinese = chinese;
this.english = english;
}
void score(){ //计算总分方法
score= math+chinese+english;
System.out.println(score);
}
void ave(){ //计算平均分方法
average = score/3;
System.out.println(average);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
Student s = new Student(101,"kit","male",true,90.0,90.0,90.0); //创建对象
s.score(); //调用方法
s.ave();
}
}
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
public class Student{
String number;
String name;
String sex;
boolean isLeader;
float math;
float yuwen;
public Student(String number,String name,String sex, boolean isLeader,
float math,float yuwen){
this.number=number;
this.....
....
}
}
String number;
String name;
String sex;
boolean isLeader;
float math;
float yuwen;
public Student(String number,String name,String sex, boolean isLeader,
float math,float yuwen){
this.number=number;
this.....
....
}
}
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
public class Student{
int studentId;
String Name;
String gender;
boolean isGender;
int manthScore;
int chaneseScore;
}
int studentId;
String Name;
String gender;
boolean isGender;
int manthScore;
int chaneseScore;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询