Write a program to display characteristics of a ball thrown straight up into the air.(C Language) Ask
Question:
Write a program to display characteristics of a ball thrown straight up into the air.(C Language)
Ask the user for the initial height of the ball (in feet) and the initial velocity of the ball (in feet per second). Validate that both values are greater than or equal to 0. Then, calculate and display:
- The maximum height the ball will reach (in feet) The ball will reach its maximum height after v/32 seconds, where ‘v’ is the initial velocity
- The number of seconds it will take for the ball to hit the ground (in 0.1-second intervals) Calculate the height of the ball after every 0.1 seconds to determine when the ball height is either 0 or a negative value (Use a loop)
- A table showing the height of the ball every 0.25 seconds until the ball is on the ground Calculate the height of the ball after every 0.25 seconds, display both the time and the height, and stop when the height is either 0 or a negative value (Use a loop)
The formula for the height of the ball at any instance in time is: h + v * t - 16 * t^2
where:
h = the initial height of the ball (in feet)
v = the initial velocity of the ball (in feet per second)
t = time (in seconds)
Make sure that you use the above formula and not any other formula you might find (otherwise, your results and mine may not be the same).
Display a blank line between the inputs and the maximum height and time to hit the ground, and between the maximum height and time to hit the ground and the table of heights every 0.25 second.
- Validation error messages are indented 3 spaces
- Account for an initial velocity of 0 and/or an initial height of 0
- When calculating when the ball will hit the ground, if the ball starts at an initial height of 0.0 ft., start with the ball’s height after 0.1 second
- The table to display the ball’s height every 0.25 seconds may require a post-test loop, with the first line of the table outside the loop
- If the ball has an initial height of 0.0 ft., and an initial velocity of 0.0 ft. per sec., only display the first line of the table
- Use a tab to align the 2 nd column (the Height column) in the table
Physics for Scientists and Engineers A Strategic Approach with Modern Physics
ISBN: 978-0133942651
4th edition
Authors: Randall D. Knight