[Java]练习题010: 求小球的高度和运行的距离

    技术2022-05-18  19

    【程序10 题目:一球从100米高度自由落下,每次落地后反跳回原高度的一半;再落下,求它在 第10次落地时,共经过多少米?第10次反弹多高?

     

    public class Test10 { public static void main (String[] args) { double h = 100; double sub=0; for(int i=1;i<=10;i++) { sub = sub+h; h = h/2; } System.out.println("第10次落地时,小球运行的距离为:" +sub); System.out.println("第10次弹起后的高度为:"+h); } } 


    最新回复(0)