Can anyone help to make this program in c++? The code is supposed to calculate a
ID: 3758934 • Letter: C
Question
Can anyone help to make this program in c++? The code is supposed to calculate and output the range and height of a projectile.
Equations
newXpos = oldXpos + timeInterval * oldXVel
newYpos = oldYpos + timeInterval * oldYVel
newXvel = oldXvel + timeInterval * Xacceleration
newYvel = oldYvel + timeInterval * Yacceleration
Yacceleration = -9.81 + time
X acceleration = -time // it changes with time
muzzleVelocity = 50;
InitialXVel = muzzleVelocity * cos(elevationAngle)
InitialYvel = muzzleVelocity * sin(elevationAngle)
timeInterval = .001 seconds
Units
Seconds
Meters
Course objectives
You must use functions to update position, velocity, and acceleration.
You must use arrays for the position, velocity, and acceleration vectors.
Bonus points for students who can find the maximum range of the system.
You must prompt the user for initial input of elevation angle.
You must output the time, the height, and the downrange distance at each increment of time. (instantaneous states)
You program must terminate when the projectile strikes the ground.
You must use the “+=” operator.
All data must be output with three decimal places. (use setprecision)
All columns must be aligned. (use setw)
First the program must prompt the user for input.
The user then inputs the cannon elevation angle.
Then it must incrementally calculate and output projectile range and height.
Your output should match both the content and formatting shown above.
You must suspend the process with an input statement “cin.get();” to do this.
Explanation / Answer
I have this really hard assignment in which I have been trying to work on but I dont get where to start. I need to calculate the trajectory of a projectile given the following equation.
2 2 2
y = x * tan(theta) - (g * x ) / (2 * v * cos(theta))
where v is the initial speed (ft/sec), theta is the angle of projection, and g is the acceleration (32 ft/secsquare) due to gravity. In the formula above, y is height of the projectile and x is the horizontal distance from the
starting point.In this assignment, you will create a table of y vs. x (height vs. distance)
values as shown below:
distance height
5.00 4.66
10.00 8.62
15.00 11.88
20.00 14.45
25.00 16.33
30.00 17.51
35.00 18.00
40.00 17.79
45.00 16.89
50.00 15.29
55.00 12.99
60.00 10.01
65.00 6.32
70.00 1.95