The following formula can be used to describe the dimensions of a loading ramp:
ID: 3778568 • Letter: T
Question
The following formula can be used to describe the dimensions of a loading ramp:
sin( ) = h
l
where is the incline angle of the ramp, h is the height of the ramp, and l is the
length of the ramp. Write a program that calculates the needed length of a ramp
given a desired incline and height. For example, given an incline of 9.5 degrees
and a height of 0.5 m, a ramp needs to be 3.03 m in length. The program should
prompt the user for the needed values and calculate and report the required
length. The program should make use of the math library for the sin() function,
and should use the macro M_PI for the value of to convert degrees to radians
(radians = degrees ×
180 ).
Explanation / Answer
# include<iostream.>
# include<math.h>
#include<conio.h>
float radians,degrees,h,l;
//define PI value
#define PI 3.14
//macro which calculates the angle in radians
#define M_PI ((radians=degrees*PI)/180)
void main()
{
//enter the degrees
cout<<"Enter the sign value in degrees"<<endl;
cin>>degrees;
//enter height h as 0.5m
cout<<"Enter the height in metre"<<endl;
cin>>h;
//enter length l as 3.03m
cout<<"enter the length in metre"<<end;
cin>>l;
//formula to calculate the dimensions i.e report required for length
sin(M_PI)=hl;
//print the result
cout<<"The report required for length is "<<sin(M_PI)<<endl;
getch();
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.