A ball drops freely from 100 meters, and each time it hits the ground, it jumps back to half its original height and falls again, when it hits the ground for the tenth time
/ * *
** * Project Name: One * File Name: TestBall * * @version 1.0 * @author:wenerduo * @Date: 2022/03/20/下午 8:07 * Copyright (c) 2022, */ public class TestBall { public static void main(String[] args) { Double height1=100.00; Double rh1=0.00; Double z1=100.00; for(int i2=1;i2<11;i2++){ /* 球第一次落地时,此时并没有反弹, 除去第一次落地,后面的落地总高度都应该加上反弹高度的2倍 */ if(i2!=1){ rh=(height1/2); height1=rh1; z+=(height1*2); } System.out.println("第"+i+"次落地球经过的总高度为:"+z+" ,反弹的高度是:"+rh); } } }