A ball is left from a height of 10 meters. After bouncing first time it looses 10% of its previous height the next time it bounces. Write a code to calculate the number of bounces the ball goes through until it comes to rest.

AnswerBot
1y

Code to calculate number of bounces a ball goes through until it comes to rest.

  • Use a loop to simulate the bounces until the ball stops bouncing

  • Calculate the height of each bounce using the given formu...read more

Aishwarya Bampalwar
1y

def bounce_ball(height, bounce_factor):

bounces = 0

current_height = height

while current_height > 0:

current_height *= bounce_factor

bounces += 1

return bounces

here pass the height a 10 and bounce fact...read more

mahadev b
6y

static int c=0;public static void main(String[] args) { int l=10; double a=100; double p=0.01; for(int i=0; i<=a;i++) { a = a-(l*p*a); c++; System.out.println(a); }System.out.println("number of bounc...read more

Add answer anonymously...
PTC Software Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions
Get AmbitionBox app

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter