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
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
Wedw Detu Enter the initial height of the ball (in ft.): 20 Enter the initial velocty of the ball (in ft. per sec.): 1e Salution Eyp The maximum height the ball will reach is 21.6 feet. The time for the ball to reach the ground is 1.5 seconds. Time 0.00 e.25 0.50 e.75 1.00 1.25 1.50 Height 20.0 21.5 21.0 18.5 14.0 7.5 0.0 Press any key to continue ... la C Ve Popety Man Ta l ELi S- Goegle O Gade Cent-Spr Sales Comminion Bal- Micvat Vi
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started