JAVA编程题目

JAVA编程题目,考试用,着急谢谢大家... JAVA编程题目,考试用,着急谢谢大家 展开
 我来答
ijava学习网
2018-06-21 · 国内最优秀java资源共享平台
ijava学习网
国内最优秀的java免费资源共享及学习平台,专注从实战中学习与成长。主要包括教程、经验分享、知识、资讯、工具、手册、视频及各种资源下载。
向TA提问
展开全部
public class Student {

private String code;
private String name;
private int height;
private char sex;

public Student() {
super();
// TODO Auto-generated constructor stub
}
public Student(String code, String name, int height, char sex) {
super();
this.code = code;
this.name = name;
this.height = height;
this.sex = sex;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getHeight() {
return height;
}
public void setHeight(int height) {
this.height = height;
}
public char getSex() {
return sex;
}
public void setSex(char sex) {
this.sex = sex;
}

public String show(){
return "Student [code=" + code + ", name=" + name + ", height=" + height + ", sex=" + sex + "]";

}

public int show(Student s){

return s.getHeight();

}
public void show(Student s,int sv){
if(s.getHeight()>=sv){
if(s.getSex()=='f'){
System.out.println(s.show());
}
}

}

}

public class Test {

public static void main(String[] args) {

Student student1 = new Student("A001", "zs1", 171, 'm');
Student student2 = new Student("A002", "zs2", 172, 'f');
Student student3 = new Student("A003", "zs3", 173, 'm');
Student student4 = new Student("A004", "zs4", 174, 'f');
Student student5 = new Student("A005", "zs5", 175, 'f');
System.out.println(student1.show());
System.out.println(student2.show());
System.out.println(student3.show());
System.out.println(student4.show());
System.out.println(student5.show());
//平均身高
int sv=(student1.show(student1)+student2.show(student2)+student3.show(student3)+
student4.show(student4)+student5.show(student5))/5;

System.out.println("超过平均年龄的女生详情:");
//超过平均年龄的女生
student1.show(student1, sv);
student2.show(student2, sv);
student3.show(student3, sv);
student4.show(student4, sv);
student5.show(student5, sv);

}

}
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式