Assignment 1: C++
Write a program to compute the optimal angle at which to kick a ball from the ground with a fixed speed such that it travels the farthest distance before hitting the ground.
Assume that there is no friction, so that the trajectory of the ball will be given by
\[ x(t) = v t \cos(\theta) \]
\[ y(t) = v t \sin(\theta) - gt^2/2\]
Here, x and y are the horizontal and vertical position of the ball, t is time, g is the gravitational acceleration, v is the initial speed of the ball, and \(\theta\) is the initial angle of the trajectory.
Your program should take the value of v as input from cin, find the angle for which the distance is maximal, and print out the value of the angle and the distance.
Although this problem can actually be solved exactly, your code should find the distance traversed by computing the trajectory of the ball at regular small time intervals.
In your code, use best practices such as using several functions with interface and implementation separated, good commenting and checking for errors.
In addition to your code, your submission should also contain a text file with a brief explanation of your implementation, how you compiled the code, and how you ran it.
The deadline for this assignment is January 25th, 2024. Late assignments are possibly up to one week later at a penalty of 5% of your mark per day late.
Note about using ChatGPT: Beyond using Large Language Models like ChatGPT as a better search engine, you should not rely on them to do your assignments. While LLMs might give a near-solution, its code would have problems that you would have to fix anyway. Furthermore, they tend to only generate a few different variants of the same solution and that would get your submission flagged as being a copy of another student's submission, which is not allowed. Also, future assignment will increasingly get more specialized, and ChatGPT's solutions would get even further from the correct answer.