Answer to Question #236589 in C++ for piyumali

Question #236589

Write a C++ program to calculate the maximum height when the user gives the angle (in degrees). The given below is the equation to calculate the maximum height.




v = 10.568 (initial velocity), g = 9.8 (acceleration due to gravity), θ = angle of the initial velocity from horizontal plane in radians and H = maximum height

Note: Assign the above values for v, g and PI. Consider the g (acceleration due to gravity) is a constant.

  • User may insert an angle below 20° and above 10°.
  • Then the program should calculate the maximum height (H) for each angle only when the angle below 20°.
  • 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:50:02-0400
#include<iostream>
#include<math.h>
using namespace std;


float computingSin(float number) {    
    float result = 0.0001, denom, sin_x, sin_val;
    number = number * (3.142 / 180.0);  //Changing the angle to radians
    float t= number;
    sin_x = number;          
    sin_val = sin(number);    
    int x = 1;
    do {
        denom = 2 * x * (2 * x + 1);
        t = -t * number * number / denom;
        sin_x = sin_x + t;
        x = x + 1;
    } while (result <= fabs(sin_val - sin_x));
    return sin_x;
}
int main(){
	cout<<"Enter the starting angle\n";
	int angle;
	cin>>angle;
	float v0 = 10.568;
	for(int i=angle; i<=20; i++){
		float H =  ((v0 * v0) * pow(computingSin(i), 2)) / (2 * 9.8); 
		cout<<"Maximum height for angle "<< i  <<" is: "<<H<<endl;
	}
	
}

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