Beta

Fire your cannons!

Description:

You are a pirate, and your captain wants you to help him figure out how far he can launch a cannonball.

The captain fires a cannonball from a cliff with a height of h metres above sea level with a velocity of v ms^-1 at an upward angle of theta degrees to the ground into the ocean.

The captain now wants you to work out the cannonball's maximum height, and the horizontal distance the cannonball travelled.

Input = cannonball(theta,v,h)

  • theta = the angle between the surface and the direction of the cannonball. It is parallel to the ground (in degrees)

  • v = initial velocity of the cannonball (in ms^-1)

  • h = initial height of the cannonball (in m)

Outputs = (maxh, distance)

  • maxh = the maximum height of the cannonball

  • distance = the horizontal distance the cannonball travels

Assume air resistance is negligible and that the gravitational constant g = 9.81 ms^-2. Assume that all inputs will be positive numbers less than 100.

Example: The captain fires his cannon from a height of 10m with a velocity of 40ms^-1 at an upward angle of 30° from the ground.

cannonball(30,40,10) = (30.387359836901116, 156.84578865761307)

  • Maximum height = 30.4m
  • Horizontal distance = 156.8m

Below is a fantastic sketch made by me visualizing this problem

Physics

Stats:

CreatedDec 21, 2024
PublishedDec 21, 2024
Warriors Trained34
Total Skips5
Total Code Submissions31
Total Times Completed17
Python Completions17
Total Stars5
% of votes with a positive feedback rating75% of 8
Total "Very Satisfied" Votes4
Total "Somewhat Satisfied" Votes4
Total "Not Satisfied" Votes0
Total Rank Assessments7
Average Assessed Rank
7 kyu
Highest Assessed Rank
6 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • patbs Avatar
Ad