Question: This should be programmed in C++ using multiple files, in Visual Studio. Include a Driver, Header, and Function file: In main, declare an array of
This should be programmed in C++ using multiple files, in Visual Studio. Include a Driver, Header, and Function file:
In main, declare an array of doubles to hold the coordinates of the location of a bullet as time passes. There is no target, so the bullet will eventually slow down and hit the ground. Use a 2D array for this. Size the array(const int SIZE{100}) for 100 rows, and 2 columns(double axiPosition[SIZE][2]).
Open a do-while or while loop. Call AskUser Function to ask the user for the angle from which the bullet is shot. This angle is measured in degrees. Remember to convert the degrees to radians, as this is what C++ uses. The function AskUser also asks the user for the velocity, of the bullet in m/s.
Take into account gravity, which should be declared as const grav{9.81}. You will also need to assign the constant for PI. (3.14159).
We will need the velocity in the y-axis and in the x-axis. Call the Fire Function, which will calculate the velocity in both x and y planes. Fire will then call a function called Trajectory, which will calculate the x and y positions of the bullet in intervals of 1 second.
Stop the calculations and filling of the array when the y axis becomes negative, as this is ground level. Fire will assign the positions into the array that tracks the position of the bullet. These intervals will fill the created array with the x and y positions of the bullet. Fire recalculates the y axis velocity and calls Trajectory again.
From main, display the initial velocity and angle of the bullet, then the x and y positions for each second. Then call a WriteFile Function to write your position data to an excel file of any type.
Display final results to the user, and ask if they would like to calculate another shot. If yes, repeat program. If no, output a goodbye message letting the user know the program has exited successfully.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
