Question: (3) (20 points) A classic physics experiment is to drop the ball and see how high it bounces. Once the bounciness of the ball is
(3) (20 points) A classic physics experiment is to drop the ball and see how high it bounces. Once the "bounciness" of the ball is determined, the ratio gives a bounciness index. For example, if a ball dropped from a height of 10 feet bounces 6 feet high, the index is 0.6, and the total distance traveled by the ball is 16 feet after one bounce. If the ball were to continue bouncing, the distance after two bounces would be 10 ft + 6 ft + 6 ft + 3.6 ft = 25.6 ft. Note that the distance traveled for each successive bounce is the distance to the floor plus 0.6 of that distance as the ball comes back up. Write a program that lets the user enter the initial height from which the ball dropped and the number of times the ball is allowed to continue bouncing. The output should be the total distance traveled by the ball. After some bounces, the bounce height reaches < 0.1 ft. Then, your program stops the computation and displays the results: Results: Enter the height from which the ball dropped: 10 enter the ball bounce index: (0.6) 0.6 Enter the number of times the ball is allowed to continue bouncing: 1000 height is <= 0.01 at bounce # 13 The total distance traveled is 39.968654334361595 feet.
(4) (20) In a typical "high-low" number guessing game, the computer generates a random number, and we (humans) input the guess until a correct one is detected. Write a program where these roles are reversed: the user (human) thinks of a number X for the computer to guess. Then, similar to the human guessing version, the user must provide "<" and ">" to indicate smaller and higher for the computer to adjust the next guessing. Finally, the user enters "= " when the computer guess is correct. The user must initially input the number range(lower and upper) bounds. The 'secrete' number must be anywhere within the bounds. Next, the computer must complete the maximum number of guesses needed based on the equation: round (log2 (high low) +1 ). Your program needs to track the number of guesses. If the number of guesses is larger than the maximum, display the message "you are cheating!" (as you, the user change the initial number X during guessing) For the following example: ( my initial number was 20) Enter the smaller number: 1 Enter the larger number: 120 Your number is 60 Enter =, <, or >: < Your number is 30 Enter =, <, or >: < Your number is 15 Enter =, <, or >: > Your number is 22 Enter =, <, or >: < Your number is 18 Enter =, <, or >: > Your number is 20 Enter =, <, or >: = Hooray, I've got it in 6 tries! For this example, the secret number is 75. After the guess of 60, I was "misled" about the direction. Enter the smaller number: 10 Enter the larger number: 110 Your number is 60 Enter =, <, or >: < Your number is 34 Enter =, <, or >: > Your number is 47 Enter =, <, or >: > Your number is 53 Enter =, <, or >: > Your number is 56 Enter =, <, or >: > Your number is 58 Enter =, <, or >: > Your number is 59 Enter =, <, or >: > You're cheating! Process finished with exit code 0
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
