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

Newton\'s laws of motion predict the height H of an object at time T with an ini

ID: 668405 • Letter: N

Question

Newton's laws of motion predict the height H of an object at time T with an initial velocity V and initial angle of movement A. Ignoring friction, the equation is H = sin(A)VT - 0.5gT^2 where g denotes the acceleration due to gravity. Assume the constant g = 32.174 ft/sec^2. For example, an American football thrown at an angle A of 40 degrees, with an initial velocity V of 88 ft/sac, in time T = 2 seconds is at a height of 48.7825 feet. Write a complete C++ program using a while loop that inputs the angle A in degrees and velocity V in ft/sec, and outputs the height of the object every 0.2 seconds, starting at 0.0 seconds and ending at 2.0 seconds. For example, if the inputs are 40.0 and 88.0, then the correct output are the following 11 values: 10. 6696 20. 0522 28.1478 34 . 9565 40. 4783 44 . 713 47. 6609 49 . 3217 49. 6956 48 . 7825 Note that C++ provides a built-in sine function, sin(R). However, this function works in radians, not degrees, so convert A to radians using R = A * Pl / 180; define PI=3.14159.

Explanation / Answer

// Program using DEV C++ editor

#include <iostream>

#include <math.h>

using namespace std;

float degreeToRadian(float);

float PI=3.14159;

int main()

{

float g=32.174; // accelaration due to gravity

float A,R,H,V;

float T=0.0;

cout<<"Enter the Angle in Degrees:";

cin>>A;

cout<<"Enter the Velocity in ft/sec:";

cin>>V;

cout<<endl<<"Height in feets:";

while(T<=2.0)

{

               R=degreeToRadian(A);

               H=sin(R)*V*T-(0.5*g*pow(T,2));

               T=T+0.2;

               cout<<endl<<H;

}             

return 0;

}

float degreeToRadian(float degree)

{

               float Radian=degree *PI /180;

               return Radian;

}

------------------------------------------------------------------------------------------------------------------

// Output

Enter the Angle in Degrees:40

Enter the Velocity in ft/sec:88

Height in feets:

0

10.6696

20.0522

28.1478

34.9565

40.4783

44.713

47.6609

49.3217

49.6956

--------------------------------