topic
A ball falls freely from a height of 100 meters, and rebounds back to half of its original height each time it hits the ground. When it falls again, how many meters does it travel when it hits the ground for the 10th time? How high is the 10th rebound?
public class pinBall {
public static void main(String[] args) {
double h = 100,s = 100;
for(int i=1; i<10; i++) {
s = s + h;
h = h / 2;
}
System.out.println("经过路程:" + s);
System.out.println("反弹高度:" + h / 2);
}
}