Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

of a Create a ball. that calculates the trajectory of a free-falling ball, subje

ID: 3574018 • Letter: O

Question

of a Create a ball. that calculates the trajectory of a free-falling ball, subject to the following program initial conditions. i. Initial height of ball at release, h 1.5 m ii. Gravitational acceleration, g 9.8 m/s iii. Veloci of ball at release, v 4 m/s iv. Angle of the velocity vector at time of release, 0 E45 degrees b. Your program should tabulate the x distance and y height of the ball for time instances t 0.001 s, 0.002 s 1.000 s as shown in Table l.Use equations (1) and (2) for the relevant computations x(t) v cos (0 180 (1) (2) y(t): h+ v sin (0 gt ll

Explanation / Answer

C++ Program:

#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;

   double time; //time declaration
   const double GRAVITY = 9.8 / time; //gravity decleration
  
int main()
{
   int i;
   int height;
   double distance=0;
   double fallingDistance;

      
   while(time != -1) //while loop started from here
   {

       cout << "Kindly input the time of fall in secs: ";
       cin >> time;

       cout << "Kindly input the height of the bridge in meters: ";
       cin >> fallingDistance;

      
   for(i=0; i<time; i++)
   {
       time = i + 1.0;
       cout << "Given gravity of, " << GRAVITY << " meters per second squared, an object will fall "
<< distance << " meters in " << time << " seconds." << endl;
   }

       distance = 1/2 * GRAVITY * pow(time,2);
       //distance = (0.5 * gravity * (seconds * seconds));

       cout << "Distance: " << distance << endl;

       if (distance > fallingDistance)
       {
           cout << " Warning Bad Data: The distance Fallen exceeds the height of the bridge. ";
       }


   }

   system("pause");
   return 0;

}

Matlab program :

clc,clf,clear
g=9.8; theta0=45*pi/180; v0=4;
t(1)=0;x=0;y=0;
plot(x,y,'o','MarkerFaceColor','b','MarkerSize',8)
axis([0 3 0 0.8])
M(1)=getframe;
dt=1/128;
for j = 2:1000
t(j)=t(j-1)+dt;
x=v0*cos(theta0)*t(j);
y=1.5 + v0*sin(theta0)*t(j)-0.5*g*t(j)^2;
plot(x,y,'o','MarkerFaceColor','b','MarkerSize',8)
axis([0 3 0 0.8])
M(j)=getframe;
if y<=0, break, end
end
pause
movie(M,1)