Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started