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: 3885304 • 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 - (1/2)gT^2 where g denotes the acceleration due to gravity. Assume the constant g = 32.174 ft/sec^2. Example: an American football thrown at an angle A of 40 degrees, with an initial velocity V of 88 ft/sec, will have a height H of 48.7825 feet at time T = 2 seconds. Write a complete C++ program to compute the height of an object based on Newton's laws of motion. Your program should input 3 real numbers: the angle A, the initial velocity V, and the time T, in this order. Example: 40.0 88.0 2.0 For this input, your program should compute and output the following height, including the unit "feet" and followed by a newline: Height: 48.7825 feet However, if any of the inputs are invalid (i.e. negative), do not compute the height, and instead output the message "invalid input" followed by a newline. This message should appear once, even if there are multiple invalid inputs. A few things to note about the equation. The ^ is used to denote exponentiation, but ^ does not work this way in C++; use the pow() function, or simply multiply. And beware of the factor 1/2 --- recall what happens when the computer performs integer division... Rewrite this factor to something that works. Finally, C++ provides a sine function, sin(R). However, this function works in radians, not degrees, so convert A to radians using R = A * PI / 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

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote