Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a menu driven C++ program with three functions of yours (sind, cosd, tand

ID: 3806193 • Letter: C

Question

Create a menu driven C++ program with three functions of yours (sind, cosd, tand),

calculating sin, cos, and tan trigonometric functions with the input values being in

degrees. You are required to create those three functions and invoke them from the

main program in order to receive any credit.

Purpose of the program : Writing functions.

Calculate trigonometric functions with input value in degrees.

Section 1 : Show a menu and receive a selection from a user.

Section 2 : Enter a number in degrees.

Section 3 : Invoke appropriate function you wrote, show the answer.

Section 4 : Repeat Section 1 through Section 3 until user specifies

Trigonometric Functions in Degrees. Please select a function to be performed S/s: sin C/C: COS T/t tan E/e: Exit Please enter your selection: s You selected sin. Please enter a value in degrees 150 sin (150 degrees) 0.5 Please select a function to be performed: S/s sin C/c cos T/t: tan E/e: Exit Please enter your selection: C you selected cos Please enter a value in degrees 240 os(240 degrees 0.5 Please select a function to be performed: S/s sin C/C COS /t tan E/e: Exit Please enter your selection: T you selected tan Please enter a value in degrees 225 5 degrees 1 Please select a function to be performed: S/s sin C/c: cos T/t: tan E/e Exit Please enter your selection: X you entered invalid selection. Please select a function to be performed: S/s sin C/c COS T/t: tan E/e Exit Please enter your selection: e Program terminates. Good Bye

Explanation / Answer

// C++ code
#include <iostream>
#include <math.h>
using namespace std;


char menu()
{
   char selection;
   cout << "Please select a fuction to be performed: ";
   cout << " S/s: sin C/c: cos T/t: Tan E/e: EXIT Please enter your selection: ";
   cin >> selection;
   return selection;
}

void calculateSin()
{
   double degrees;
   cout << "You selected Sin ";
   cout << "Please enter a value in degrees: ";
   cin >> degrees;

   double radian = degrees*((22.0/7)/180.0);
   cout << "sin(" << degrees << ") = " << sin(radian) << endl;
}
void calculateCos()
{
   double degrees;
   cout << "You selected Cos ";
   cout << "Please enter a value in degrees: ";
   cin >> degrees;

   double radian = degrees*((22.0/7)/180.0);
   cout << "cos(" << degrees << ") = " << cos(radian) << endl;
}
void calculateTan()
{
   double degrees;
   cout << "You selected Tan ";
   cout << "Please enter a value in degrees: ";
   cin >> degrees;

   double radian = degrees*((22.0/7)/180.0);
   cout << "tan(" << degrees << ") = " << tan(radian) << endl;
}

int main()
{
          
   while(true)
   {
       int selection = menu();

       if(selection == 'S' || selection == 's')
       {
           calculateSin();
       }
       else if(selection == 'C' || selection == 'c')
       {
           calculateCos();
       }
       else if(selection == 'T' || selection == 't')
       {
           calculateTan();
       }
       else if(selection == 'E' || selection == 'e')
       {
           cout << "Program terminates. Good Bye! ";
           break;
       }
       else
           cout << "Invalid Input ";
   }
   return 0;
}


/*
output:

Please select a fuction to be performed:
   S/s: sin
   C/c: cos
   T/t: Tan
   E/e: EXIT
Please enter your selection: s
You selected Sin
Please enter a value in degrees: 150
sin(150) = 0.499087
Please select a fuction to be performed:
   S/s: sin
   C/c: cos
   T/t: Tan
   E/e: EXIT
Please enter your selection: c
You selected Cos
Please enter a value in degrees: 260
cos(260) = -0.171849
Please select a fuction to be performed:
   S/s: sin
   C/c: cos
   T/t: Tan
   E/e: EXIT
Please enter your selection: t
You selected Tan
Please enter a value in degrees: 225
tan(225) = 1.00317
Please select a fuction to be performed:
   S/s: sin
   C/c: cos
   T/t: Tan
   E/e: EXIT
Please enter your selection: e
Program terminates. Good Bye!


*/

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote