In: Computer Science
Write a program that asks the user for an angle, entered in radians. The program should then display the sine, cosine, and tangent of the angle. (Use the sin, cos, and tan library functions to determine these values.) The output should be displayed in fixed-point notation, rounded to four decimal places of precision
Take your previous Angle Calculator program and modify it to do a table of trig values. The columns will be: Degrees, Sine, Cosine, Tangent,. And the rows will go from 0° to 90° in increments of 10°. This needs to be displayed on the screen and on a .txt file
c++
Code
#include <iostream>
#include <iomanip>
#include <string>
#include <stdio.h>
#include <cmath>
#include<fstream>
using namespace std;
int main()
{
const int START_DEGREE = 0;
const int END_DEGREE = 90;
const int INCREMENT = 10;
float radian;
ofstream out("a.txt");
out << setprecision(4) << fixed;
out.width(15);out<<left<<"Degree";
out.width(15);out<<left<<"Sine";
out.width(15);out<<left<<"Cosine";
out<<left<<"Tangent"<<endl;
for (int i = START_DEGREE; i <= END_DEGREE; i += INCREMENT)
{
out.width(15);out<<left<<i;
out.width(15);out<<left<<sin(i);
out.width(15);out<<left<<cos(i);
out<<left<<tan(i)<<endl;
}
out.close();
}
Output
a.txt
If you have any query regarding the code please ask me in the comment i am here for help you. Please do not direct thumbs down just ask if you have any query. And if you like my work then please appreciates with up vote. Thank You.