R=v2 sin2&/g
v = 30.0 (speed of the throwing), g = 9.8 (gravity), and $= angle in radians
User may insert an angle above or equal 45° and below 60° as the highest angle.
Then the program should calculate the horizontal range of the projectile motion (R) for each angle until the angle become 35°.
Consider the gravity (g) as a constant.
You are required to calculate the 𝜃 in radians by using the given formula (PI = 3.14286 which is a constant).
Use the necessary header files to do the calculation.
#include<iostream>
using namespace std;
float convertToRadian(float angle)
{
float const PI = 3.14286;
float rad;
rad=(angle*PI)/180;
return rad;
}
float calculateRange(float angle){
float radians=convertToRadian(angle);
float const V=30.0;
float const g= 9.8;
return (pow(V,2)*sin(2*radians))/g;
}
int main()
{
float angle;
cout<<"Enter the angle of projection in degrees: ";
cin>>angle;
if(angle<45 || angle>60)
{
cout<<"The angle is out of range.";
}
else
{
for(int a=angle;a>=35;a--)
{
cout<<"\nRange of projectile for angle = "<<a<<" is: "<<calculateRange(a);
}
}
cin>>angle;
}
Comments
Leave a comment