The maximum height reached by a ball thrown with an initial velocity, v, in meters/sec, at an angle of θ is given by this formula:
height = (.5 × v2 × sin2 θ) / 9.8
Using this formula, write, compile, and run a C++ program that determines and displays the maximum height reached when the ball is thrown at 5 mph at an angle of 60 degrees. (Hint: Make sure to convert the initial velocity into the correct units. There are 1609 meters in a mile.) Calculate the maximum height manually, and verify the result your program produces. After verifying that your program works correctly, use it to determine the height reached by a ball thrown at 7 mph at an angle of 45 degrees.
#include<iostream>
#include <cmath>
using namespace std;
int main()
{
double x,v;
cout<<"Enter the degrees: ";
cin>>x;
cout<<"Enter the velocity: ";
cin>>v;
double m=sin(x);
double q=0.5*v*m*1609*m;
double y=q/9.8;
cout<<"The maximum height reached by the ball is: "<<y;
}
Height reached is: 416.063
Comments
Leave a comment