码迷,mamicode.com
首页 > 其他好文 > 详细

球自由降落问题

时间:2015-09-05 20:37:20      阅读:191      评论:0      收藏:0      [点我收藏+]

标签:

package javabasi;
/**
 * 题目:一球从100米高度自由落下,每次落地后反跳回原高度的一半;再落下,求它在   第10次落地时,共经过多少米?第10次反弹多高?
 * @author dlmu
 *
 */
public class BallBounce {
    public static void main(String[] args) {
        double height = 100;
        double length = 0;
        for (int i = 1; i <= 10; i++) {
            length = length + height;
            height = height / 2;

        }
        System.out.println("after 10 times, the final height is:" + height);
        System.out.println("total length it has passed is:" + length);
    }
}

逻辑要明确,计算清楚,看清题

球自由降落问题

标签:

原文地址:http://www.cnblogs.com/fthjane/p/4783746.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!