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

Computer-Science Menu Driven Program This is an exercise for a menu-driven progr

ID: 671172 • Letter: C

Question

Computer-Science Menu Driven Program This is an exercise for a menu-driven program. Write a program that displays the following menu: Using C++ Math Library 1. Display the square root of a number 2. Display the cosine of a number 3. Display the sine of a number 4. Quit Enter your choice (1-4) If the user enters 1, the program should ask for a number (double data type) and then display the square root of that number. If the user enters 2, the program should ask for a number (double data type) and then display the cosine value of that number. If the user enters 3, the program should ask for a number (double data type) and then display the sine value of that number. If user enters 4, the program should end.

Explanation / Answer

#include <iostream>
using namespace std;
#include <math.h>
int main(){

   int ch;
   double num;
   while(1){
       cout<<"Enter your choice ";
       cin>>ch;
       switch(ch){
           case 1:cout<<"Enter a number ";
           cin>>num;
           cout<<"Square root of number is "<<sqrt(num)<<endl;
           break;
           case 2:
           cout<<"Enter a number ";
           cin>>num;
           cout<<"cosine of number is "<<cos(num)<<endl;
           break;
           case 3:
           cout<<"Enter a number ";
           cin>>num;
           cout<<"sine of number is "<<sin(num)<<endl;
           break;
           case 4:
           return 0;
       }

   }
}

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