Question: I just need help rounding up the decimal. This is the question. Write aprogramthat asks the user for an angle, entered in radians. Theprogramshould then

I just need help rounding up the decimal.

This is the question. Write aprogramthat asks the user for an angle, entered in radians. Theprogramshould then display the sine, cosine, and tangent of the angle. (Use the sin, cos, and tan library functions to determine thesevalues.) All numericvaluesin theoutputshould be displayed in fixed-point notation, rounded to four decimal places of precision.

Here is one sample run:

Enter angle: 1.07078 sin(1.07078)=0.8776 cos(1.07078)=0.4794 tan(1.07078)=1.8304 

MY ATTEMPT:

#include  #include  //include iomanip library for precision commands #include  //include cmath library for the sine, cosine and tangent functions using namespace std; int main() { double angle; //declare variable to store the value of the angle in radians cout << "Enter angle: sin(1.0708)=0.8776" << endl; //prompt user to enter the value for the angle cin >> angle; //read from keyboard the angle value that the user entered cout << setprecision(4) << fixed; //setprecision(4) coupled with fixed, means 4 //decimal places will be shown cout << "cos(1.07078)=" << cos(angle) << endl; //of the sine, cosine and tangent functions cout << "tan(1.07078)=" << tan(angle) << endl; //for the angle return 0; } 

*****

Expected Output:

Enterangle:sin(1.0708)=0.8776 cos(1.0708)=0.4794 tan(1.0708)=1.8304 

Actual Output:

Enterangle:sin(1.0708)=0.8776 cos(1.07078)=0.4794 tan(1.07078)=1.8304 

*****

The cos and tan aren't rounding up

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!