Java Sphere drop problem

Source: Internet
Author: User

Title: A ball from the height of the free fall, each landing after jumping back to the original height of half, and then fall, The number of times it landed, how many meters?  How high is the first bounce?

If the number of meters takes an integer

                int gao=100;       Defines the height from the ground int sum=0;         Defines the total elapsed distance for (int i=1;i<=10;i++) {Sum+=gao;  Height of the falling gao=gao/2; The height Sum+=gao from the ground after bouncing;  The height of the drop plus the height of the bounce System.out.println ("+i+" Times the "+sum+" and "M" + "+gao+" at this time from the ground);}

Run results

If the number of meters is not rounded, change the int type to double

Output results

Java Sphere drop problem

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.