Javelin Parabolic Throw

Published by Mateusz Mędrowski in

Write a function that takes initial speed (v in m/s) and throw angle (a in degrees) and returns the maximum height and maximum range reached by javelin as a string.

Examples

javelinThrow(36.7, 45) ➞ "Ymax=34m, Xmax=137m"

javelinThrow(51.3, 20) ➞ "Ymax=16m, Xmax=172m"

javelinThrow(100.1, 89) ➞ "Ymax=511m, Xmax=36m"

Notes

  • Javelin starts moving at h=0m.
  • Gravitational acceleration is g=9.81 m/s^2.
  • All results should be rounded to the nearest whole number.
  • You can find all mathematical equations in Resources.
  • Remember that Math.sin() and Math.cos() methods don't take degree as an argument.
Watch a quick demo on how Edabit works.