Answer to Question #236627 in C++ for Tharaka

Question #236627

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.


1
Expert's answer
2021-09-13T12:18:52-0400
#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS