Question

Program 2 #include <iostream> #include <cmath> using namespace std; int main() {        const double PI...

Program 2

#include <iostream>
#include <cmath>
using namespace std;

int main()

{

       const double PI = 3.141592653;

       int degrees;

       double radians;

       cout << "Enter a value for the degree of an angle\n";

       cin >> degrees;

       // translate the formula for converting degrees to radians into C++:

       //    

       // degrees x PI

       // ------------   = radians

       //     180

       radians = _____________________________________;

       // Refer to p. 127 for help below. Note: Sine, Cosine, and Tangent

       // use radians and not degrees to compute correctly.

       cout << "The degrees entered were: " << _____________;

       cout << "\nThis equals: " << radians << " in radians\n";

       cout << "The sine of the angle entered is: " << _________________;

       cout << "\nThe cosine of the angle entered is: " << ________________;

       cout << "\nThe tangent of the angle entered is: " << _______________;

       cout << endl;

       system("pause");

       return 0;

}
Submit your program source code to the Blackboard submission module as a Word document. Include a screen shot of your output (Ctrl-Alt-Print Screen) as well. Do this for BOTH programs to receive credit for your assignment.

Sample Output:

Enter a value for the degree of an angle

45

The degrees entered were: 45

This equals: 0.785398 in radians

The sine of the angle entered is: 0.707107

The cosine of the angle entered is: 0.707107

The tangent of the angle entered is: 1

Press any key to continue . . .

0 0
Add a comment Improve this question Transcribed image text
Answer #1

C++ code:-

*******************************************************************************

#include <iostream>
#include <cmath>
using namespace std;

int main()
{
const double PI = 3.141592653;
int degrees;
double radians;
cout << "Enter a value for the degree of an angle\n";
cin >> degrees;
radians = ((double)degrees*(double)PI)/(double)180;
cout << "The degrees entered were: " << degrees;
cout << "\nThis equals: " << radians << " in radians\n";
cout << "The sine of the angle entered is: " <<sin(radians);
cout << "\nThe cosine of the angle entered is: " <<cos(radians);
cout << "\nThe tangent of the angle entered is: " <<tan(radians);
cout << endl;
system("pause");
return 0;
}
*************************************************************************************

Add a comment
Know the answer?
Add Answer to:
Program 2 #include <iostream> #include <cmath> using namespace std; int main() {        const double PI...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Flow chart of this program #include <iostream> #include <cmath> using namespace std; int mainO double sum=0.0,...

    Flow chart of this program #include <iostream> #include <cmath> using namespace std; int mainO double sum=0.0, ave-ee, int locmx, locmn int n; cout <<"Enter the number of students: "<<endl; cin >> ni double listln]; double max-0; double min-e; for (int i-e ; i<n ;i++) cout<s enter the gpa: "<cendli cin>>listli]; while (listlile i listli1>4) cout<s error,Try again "<cendl; cin>listlil: sun+=list[i]; N1 if (listli]>max) for(int isin itt) max=list [i]; 10cmx=1+1 ; else if (list [i] min) min=list [i]; locmn-i+1; ave sum/n;...

  • #include <iostream> #include <cmath> using namespace std; int main() { int x; int y; int z;...

    #include <iostream> #include <cmath> using namespace std; int main() { int x; int y; int z; int r1; int r2; cin >> x; cin >> y; cin >> z; r1 = 4* pow(x,3)-5*pow(y,2)+3*z; r2 = r1+7*pow(x,3)-2*pow(y,2)+11*z; cout << "r1="; cout << 4* pow(x,3)-5*pow(y,2)+3*z; cout << endl; cout << "r2="; cout << r1+7*pow(x,3)-2*pow(y,2)+11*z; cout << endl; cout << "r3="; cout << r2-9*pow(x,3)+22*pow(y,2)-6*z; cout << endl; return 0; } 1-115 Your output r2-395 13-186 5:Compare output Output differs. See highlights below. -163...

  • #include <iostream> #include<cmath> using namespace std; int main() { float R = 8.314; // ideal gas...

    #include <iostream> #include<cmath> using namespace std; int main() { float R = 8.314; // ideal gas constant in J/(mole-K) float F = 81; float C = (F-32)*5/9; float T = C + 273; cout << " 70 degree F = " << T << endl;    double P = 13600*(30*2.54/1000)*9.81; // P density*g*h cout << " P : " << P << " Pascal " << '\n';    double V = 10*10*5; // volume in m^3 double k_B = 1.38E-23;...

  • #include <iostream> #include <sstream> #include <string> using namespace std; int main() {    const int index...

    #include <iostream> #include <sstream> #include <string> using namespace std; int main() {    const int index = 5;    int head = 0;    string s[index];    int flag = 1;    int choice;    while (flag)    {        cout << "\n1. Add an Item in the Chores List.";        cout << "\n2. How many Chores are in the list.";        cout << "\n3. Show the list of Chores.";        cout << "\n4. Delete an...

  • Fix the following program (C++). #include <iostream> #include <cmath> #include <vector> #include <limits> using namespace std;...

    Fix the following program (C++). #include <iostream> #include <cmath> #include <vector> #include <limits> using namespace std; /* * Calculate the square of a number */ float square (float x) { return x*x; } /* * Calculate the average from a list of floating point numbers */ float average(vector<float>& values) { float sum = 0.0f; float average; for (float x : values) sum += x; average = sum / values.size(); return average; } /** Calculate the standard deviation from a vector...

  • EXPLAIN HOW THIS PROGRAM WORKS, USING DEV C++ #include <iostream> #include <cmath> #define PI 3.1415926535897 using...

    EXPLAIN HOW THIS PROGRAM WORKS, USING DEV C++ #include <iostream> #include <cmath> #define PI 3.1415926535897 using namespace std; typedef struct ComplexRectStruct {    double real;    double imaginary; } ComplexRect; typedef struct ComplexPolarStruct {    double magnitude;    double angle; } ComplexPolar; double radToDegree (double rad) {    return (180.00 * rad) / PI; } double degToRadian (double deg) {    return (deg * PI) / 180; } ComplexPolar toPolar (ComplexRect r) {    ComplexPolar p;    p.magnitude = round(sqrt(pow(r.real,...

  • #include <iostream> #include <vector> #include <iomanip> using namespace std; int main() { const int NUM_ITEMS =...

    #include <iostream> #include <vector> #include <iomanip> using namespace std; int main() { const int NUM_ITEMS = 8; vector <double> inverse(NUM_ITEMS); int j; double temp; for (int i = 0; i < NUM_ITEMS; i++) { inverse.at(i) = 1 / (i + 1.0); } cout << fixed << setprecision(2); cout << "Original vector..." << endl; for (int i = 0; i < NUM_ITEMS; i++) { cout << inverse.at(i) << " "; } cout << endl; cout << "Reversed vector..." << endl; for...

  • program. 13. What's the output of the following program? #include< iostream> #include&math> using namespace std; int...

    program. 13. What's the output of the following program? #include< iostream> #include&math> using namespace std; int p 7; void main) extern double var int p abs(-90); system( "pause"); double var = 55; 14. How many times does "#" print? forlint i 0;j< 10; +ti) if(i-2141 6) continue; cout<< "#"; 15. Write the function declaration/prototype for a, pow function b floor function 16. State True or False a. b. c. d. e. isupper function returns a double value for loop is...

  • #include <iostream> #include <cmath> #include <iomanip> #include <cstdlib> using namespace std; bool isInt (double value) {...

    #include <iostream> #include <cmath> #include <iomanip> #include <cstdlib> using namespace std; bool isInt (double value) {     double dummy;     return bool(modf(value, &dummy) == 0); } double sqr(double value) { return value * value; } double calcFrictionFactor(double R, double D, double epsilon) {     const double BlasiusCoefficient = 0.3164;     double f_old, f_new;     f_new = BlasiusCoefficient * pow(R, -0.25); // loop until our two values are within 0.000001 of each other     do {   f_old = f_new; // previous guess is now the old one...

  • Write following program using Switch statement. #include <iostream> using namespace std; int main() int number; cout...

    Write following program using Switch statement. #include <iostream> using namespace std; int main() int number; cout << "Enter an integer cin >> number; if (number > B) cout << You entered a positive integer: " << number << endl; else if (number (8) cout<<"You entered a negative integer: " << number << endl; cout << "You entered e." << endl; cout << "This line is always printed." return 0;

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT