Skip to content

Instantly share code, notes, and snippets.

@codejoust
Forked from anonymous/Anthony's Code
Created September 24, 2012 03:59
Show Gist options
  • Save codejoust/3774126 to your computer and use it in GitHub Desktop.
Save codejoust/3774126 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cmath>
using namespace std;
int main()
{
int A, B, C, dec;
double f_first, f_second, f_third, x_first, x_second, x_third;
cout << setw(60) << "Function Calculator\n\n";
cout << "Welcome to the Function Calculator. First we will calculate the value of a quadratic function for three different values of x.\n\n";
cout << "Please enter a value for A: ";
cin >> A;
cout << "Please enter a value for B: ";
cin >> B;
cout << "Please enter a value for C: ";
cin >> C;
cout << "Please enter the desired number of decimal places of accuracy: ";
cin >> dec;
cout << setprecision(dec) << fixed;
cout << "\nPlease enter a value for x: ";
cin >> x_first;
f_first = A*pow(x_first, 2)+B*x_first+C;
cout << "f(" << x_first << ") = " << f_first;
cout << "\n\nPlease enter a second value for x: ";
cin >> x_second;
f_second = A*pow(x_second, 2) + B*x_second + C;
cout << "f(" << x_second << ") = " << f_second;
cout << "\n\nPlease enter a third value for x: ";
cin >> x_third;
f_third = A*pow(x_third, 2) + B*x_third+C;
cout << "f(" << x_third << ") = " << f_third;
double deg_angle, rad_angle, sine, cosine, tangent, cosecant, secant, cotangent;
int dec2;
rad_angle = deg_angle*(3.14159265358979323846264/180.0);
sine = sin(rad_angle);
cosine = cos(rad_angle);
tangent = tan(rad_angle);
cosecant = 1/sin(rad_angle);
secant = 1/cos(rad_angle);
cotangent= 1/tan(rad_angle);
cout << "\n\nPlease enter an angle measure in degrees: ";
cin >> deg_angle;cout << "Please enter the desired number of decimal places of accuracy: ";
cin >> dec2;
cout << "\nThe corresponding angle in radians is: " << rad_angle;
cout << "\n\nsin(" << deg_angle << ") = " << sine;
cout << "\ncos(" << deg_angle << ") = " << cosine;
cout << "\ntan(" << deg_angle << ") = " << tangent;
cout << "\ncsc(" << deg_angle << ") = " << cosecant;
cout << "\nsec(" << deg_angle << ") = " << secant;
cout << "\ncot(" << deg_angle << ") = " << cotangent;
cout << "\n\nThank you for using the Function Calculator. Have a nice day!\n\n";
return 0;
}
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cmath>
using namespace std;
int main()
{
int A, B, C, dec;
double f_first, f_second, f_third, x_first, x_second, x_third;
cout << setw(60) << "Function Calculator\n\n";
cout << "Welcome to the Function Calculator. First we will calculate the value of a quadratic function for three different values of x.\n\n";
cout << "Please enter a value for A: ";
cin >> A;
cout << "Please enter a value for B: ";
cin >> B;
cout << "Please enter a value for C: ";
cin >> C;
cout << "Please enter the desired number of decimal places of accuracy: ";
cin >> dec;
cout << setprecision(dec) << fixed;
cout << "\nPlease enter a value for x: ";
cin >> x_first;
f_first = A*pow(x_first, 2)+B*x_first+C;
cout << "f(" << x_first << ") = " << f_first;
cout << "\n\nPlease enter a second value for x: ";
cin >> x_second;
f_second = A*pow(x_second, 2) + B*x_second + C;
cout << "f(" << x_second << ") = " << f_second;
cout << "\n\nPlease enter a third value for x: ";
cin >> x_third;
f_third = A*pow(x_third, 2) + B*x_third+C;
cout << "f(" << x_third << ") = " << f_third;
double deg_angle, rad_angle, sine, cosine, tangent, cosecant, secant, cotangent;
int dec2;
cout << "\n\nPlease enter an angle measure in degrees: ";
cin >> deg_angle;cout << "Please enter the desired number of decimal places of accuracy: ";
cin >> dec2;
cout << setprecision(dec) << fixed;
rad_angle = deg_angle*(3.14159265358979323846264/180.0);
sine = sin(rad_angle);
cosine = cos(rad_angle);
tangent = tan(rad_angle);
cosecant = 1/sin(rad_angle);
secant = 1/cos(rad_angle);
cotangent= 1/tan(rad_angle);
cout << "\nThe corresponding angle in radians is: " << rad_angle;
cout << "\n\nsin(" << deg_angle << ") = " << sine;
cout << "\ncos(" << deg_angle << ") = " << cosine;
cout << "\ntan(" << deg_angle << ") = " << tangent;
cout << "\ncsc(" << deg_angle << ") = " << cosecant;
cout << "\nsec(" << deg_angle << ") = " << secant;
cout << "\ncot(" << deg_angle << ") = " << cotangent;
cout << "\n\nThank you for using the Function Calculator. Have a nice day!\n\n";
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment