Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

[JAVA Question] A particular ball bounces to 80% of its drop height. Write a pro

ID: 3831506 • Letter: #

Question

[JAVA Question]

A particular ball bounces to 80% of its drop height. Write a program which will determine
how many bounces it takes for the bounce height to be less than 30% of the initial height.
Sample output:
Original height = 100
Lower bounce height = 30.0
Bounce 1 height = 80.0
Bounce 2 height = 64.0
Bounce 3 height = 51.2
Bounce 4 height = 41.0
Bounce 5 height = 32.8
Bounce 6 height = 26.2
It takes 6 bounces to go below 30%.
Design your program so that it would work with any bounce height, bounce ratio, and lower
limit

Explanation / Answer

import java.text.DecimalFormat;

import java.util.Scanner;

public class bounceHeight {

   public static void main(String[] args)

   {

       Scanner scan = new Scanner(System.in);

       System.out.print("Original Height:");

       double org = scan.nextDouble();

       System.out.print("Bounce Ratio:");

       double ratio = scan.nextDouble();

       System.out.print("Lower bounce height:");

       double lower = scan.nextDouble();

       int count=0;

       int temp=0;

       double ll = org*lower/100;

       //DecimalFormat df = new DecimalFormat("#.0");

       while(org>ll)

       {

           org = org*ratio/100;

           count++;

          

           System.out.println("Bounce "+count+" height = "+String.format( "%.1f", org));

       }

       System.out.println("It takes "+count+" bounces to go below "+lower+"%.");

   }

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote