Write a program to provide information on the height of a ball thrown straight up into the air. The program should request as input the initial height, h feet, and the initial velocity, v feet per second. The height of the ball after t seconds is, in feet:

h+vt16t2

The program should perform the following two calculations:

  • Determine the maximum height of the ball. Note: The ball will reach its maximum height after v/32 seconds.
  • Determine the approximately when the ball will hit the ground. Hint: Calculate the height after every 0.01 second and determine when the height is not longer a positive number.

A function named getInput should be used to obtain the values of h and v and that function should call a function named isValid to ensure that the input values are positive numbers. Each of the tasks 1 and 2 should be carried out by functions. Also within one of your function you must use the return feature (you can use this feature in all functions if you want as well). Below is example of the inputs and outputs that you could get:

Enter the initial height of the ball: 5
Enter the initial velocity of the ball: 34
The maximum height of the ball is 23.06 feet.
The ball will hit the ground after approximately 2.27 seconds.
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.