例题2-5
来源:互联网 发布:mpu6050单片机电路图 编辑:程序博客网 时间:2024/05/22 05:29
public class Example5 {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
People 张三,李四;
张三=new People();
李四=new People();
Machine 体检器;
体检器=new Machine();
张三.height=200f;
张三.weight=77;
张三.speak();
体检器.estimate(张三.height, 张三.weight);
李四.height=250f;
李四.weight=80;
李四.speak();
体检器.estimate(李四.height, 李四.weight);
}
}
public class Machine {
void estimate(float height,int weight){
double number=(height-100)/weight;
if(number>=1.1)
System.out.println("偏瘦");
else if(number<1.1&&number>=0.96)
System.out.println("正常");
else if(number<0.96)
System.out.println("偏胖");
}
}
public class People {
float height;
int weight;
void speak(){
System.out.println("我的身高是"+height+"cm");
System.out.println("我的体重是"+weight+"kg");
}
}
- 例题2-5
- 例题2-5
- 例题2
- 例题5-2 木块问题 UVa101
- 例题2-2
- 例题2-2
- C语言例题5:
- 例题3--5
- 例题8.3.5
- 例题3-5
- 例题4-5
- 红皮书5个例题
- 线段树例题5
- C语言例题2:
- 例题1--2
- 例题2--3--3
- 例题3-2
- 例题5.2.2
- Linux学习笔记——Makefile教程
- ubuntu网络设置
- C# 匿名方法和Lambda表达式
- 个人站好做吗?
- servlet验证码生成
- 例题2-5
- Android——PageView轮播实现
- Adapter基础讲解-MVC模式的简单理解和Adapter概念解析
- Software Install for CentOS 7.3
- csdn如何转载别人的文章
- java连接不上hbase无异常信息
- 基于JSON级联查询(修改)省 市 区
- Detection物体检测及分类方法总结(RFCN/SSD/RCNN/FastRCNN/FasterRCNN/SPPNet/DPM/OverFeat/YOLO)
- The study of iterator in Python(20170912)