Question: NEED THIS IN PYTHON please Purpose The purpose of this assignment is to give you more practice with writing while loops. Problem The coefficient of


Purpose The purpose of this assignment is to give you more practice with writing while loops. Problem The coefficient of restitution of a ball, a number between 0 and 1 , specifies how much energy is conserved when the ball hits a rigid surface. A coefficient of 0.9 for instance, means a bouncing ball will rise to 90% of its previous height after each bounce. Write a program to input a coefficient of restitution and an initial height in meters, and report how many times a ball bounces when dropped from its initial height before it rises to a height of less than 10 centimeters (or .1 meters). The coefficients of restitution of a tennis ball, basketball, super ball, and softball are 0.7,0.75,0.9, and 0.3 respectively. Inputs Only one set of valid inputs are sufficient for program completion, meaning that you do not have to keep looping once a set of inputs have been processed. Invalid (non-numeric, out of range for coefficient of restitution) input must be caught using exceptions or otherwise. Input validation for the coefficient of restitution is to make sure the value entered is between 0 and 1 (exactly 0 and 1 are not allowed); validation for the initial height is to be at least 10cm(.1m ). When invalid inputs are entered by the user, you must loop and keep asking the user to enter new inputs until one set of valid inputs are supplied. (You don't have to create individual loops for each inputinstead, you can put both into a single loop and make the user re-enter everything if anything is invalid.) Sample Output Shown below are outputs for 3 different executions of the program. Program should run just once if the inputs are valid. Shown below are outputs for 3 different executions of the program. Program should run just once if the inputs are valid. Example 1: Enter the starting height of the ball (in meters): 8 Enter the ball's coefficient of rastitution. ERROR: Non-numeric input entered. Enter the starting height of the ball (in meters):0 Enter the ball's coefficient of restitution: 6 ERROR: Ball height must be at least 1 meters. Enter the starting height of the ball (in meters): 100 Enter the ball's coefficient of restitution: 2 ERROR: Coefficient of restitution must be between 0 and 1 . Enter the starting height of the ball (in meters): 100 Enter the ball's coefficient of restitution: 2 ERROR: Coefficient of restitution must be between 0 and 1 . Enter the starting height of the ball (in meters): 100 Enter the ball's coefficient of restitution:. 5 The ball bounced 14 time(s) before falling below .1 meters
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
