Java 之 Ball

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

编程实现:

 1 public class BallTest{
2 public static void main(String []agrs){
3 float sum=100;
4 float high = sum/2;
5 int count;
6 for(count=2; count<=10; count++){
7 sum += 2*high; //第count次落地时共经过的米数
8 high = high/2; //第count次反跳高度
9 }
10 System.out.println("the total of ball`s road is:"+sum);
11 System.out.println("the"+count+"times ball`s high is :"+high);
12 }
13 }


posted @ 2012-01-30 13:35  qin520  阅读(214)  评论(0编辑  收藏  举报