Question

In: Computer Science

Submit a menu based C++ program that can compute at least Ten Mathematical functions from <math.h>...

Submit a menu based C++ program that can compute at least Ten Mathematical functions from <math.h> or <cmath.h> library.  

The input is provided by the user.

Solutions

Expert Solution

code:

#include <bits/stdc++.h>

#include <math.h>
using namespace std;
void choice()
{
cout << "Press 1 for calculating sine value of a Number\n";
cout << "Press 2 for calculating cos value of a Number\n";
cout << "Press 3 for calculating tangent value of a Number\n";
cout << "Press 4 for calculating square value of a Number\n";
cout << "Press 5 for calculating absolute value of a Number\n";
cout << "Press 6 for calculating round value of a Number\n";
cout << "Press 7 for calculating truncated value of a Number\n";
cout << "Press 8 for calculating Floor value of a Number\n";
cout << "Press 9 for calculating ceil value of a Number\n";
cout << "Press 10 for calculating log value of a Number\n";
cout << "Press 11 to exit\n";
}
void operation(int cho,int a)
{
switch(cho){
case 1:
{
cout << "Sine value is " << sin(a) << endl;
break;
}
case 2:
{
cout << "Cosine value is " << cos(a) << endl;
break;
  
}
case 3:
{
cout << "Tangent value is: " << tan(a) << endl;
break;
}
case 4:
{
cout << "Square root is : " << sqrt(a) << endl;
break;
  
}
case 5:
{
cout << "Absolute value is: " << abs(a) << endl;
break;
  
}
case 6:
{
cout << "Round value is : " << round(a) << endl;
break;
}
case 7:
{
cout << "Truncated value is: " << trunc(a) << endl;
break;
}
case 8:
{
cout << "Floor value is : " << floor(a) << endl;
break;
}
case 9:
{
cout << "Ceiling value is: " << ceil(a) << endl;
break;
  
}
case 10:
{
cout << "Log value : " << log(a) << endl;
break;
}
case 11:
{
cout<<"Wrong input";
}
}}
int main()
{
int a;
int cho;
choice();
cout<<"Enter choice :";
cin>>cho;
cout<<"Enter value: ";
cin>>a;
operation(cho,a);
return 0;
}

output:
we can also change the datatype of the number;

thankyou


Related Solutions

C++ Write a menu based program for the pet rescue. There should be 2 menu options...
C++ Write a menu based program for the pet rescue. There should be 2 menu options -Add a pet -View pets -If the user chooses option 1, you will open a data file for writing without erasing the current contents, and write a new pet record to it. The file can be formatted any way that you choose but should include the pet's name, species, breed, and color. You my also include any additional information you think is appropriate. -If...
C++ Programming Develop and submit an original implementation of a menu-driven program performing a number of...
C++ Programming Develop and submit an original implementation of a menu-driven program performing a number of tasks relating to student marks scored in a number of assessments including: displaying all marks, adding new student marks, calculating the mean score, median score, finding the minimum and maximum scores as well as displaying the average mark of a given student. The problem: Student marks are kept in a text file as a single column. Each student may have a different number of...
Please C++ create a program that will do one of two functions using a menu, like...
Please C++ create a program that will do one of two functions using a menu, like so: 1. Do Catalan numbers 2. Do Fibonacci numbers (recursive) 0. Quit Enter selection: 1 Enter Catalan number to calculate: 3 Catalan number at 3 is 5 1. Do Catalan numbers 2. Do Fibonacci numbers (recursive) 0. Quit Enter selection: 2 Enter Fibonacci number to calculate: 6 Fibonacci number 6 is 8 Create a function of catalan that will take a parameter and return...
Write a C/C++ program that simulate a menu based binary numbercalculator. This calculate shall have...
Write a C/C++ program that simulate a menu based binary number calculator. This calculate shall have the following three functionalities:Covert a binary string to corresponding positive integersConvert a positive integer to its binary representationAdd two binary numbers, both numbers are represented as a string of 0s and 1sTo reduce student work load, a start file CSCIProjOneHandout.cpp is given. In this file, the structure of the program has been established. The students only need to implement the following three functions:int binary_to_decimal(string...
C++ Create a recursive program what will test three recursive functions. It would have a menu...
C++ Create a recursive program what will test three recursive functions. It would have a menu like: 1. Recursive factorial 2. Towers of Hanoi 3. Recursive summation 0. Exit Enter selection: 3 Enter number: 4 The recursive summation will take an integer and sum value from 1 to the integer. Don’t enter a number if the selection is 0 for quit. Please have the functions in an implementation file and the prototypes of the functions in a header file and...
This is an exercise for a menu-driven program. Program should use shell functions. Write a program...
This is an exercise for a menu-driven program. Program should use shell functions. Write a program that displays the following menu: Geometry Calculator 1. Calculate the area of a circle 2. Calculate the area of a rectangle 3. Calculate the area of a triangle 4. Quit Enter your choice (1-4) If the user enters 1, the program should ask for the radius of the circle and then display the area. Use the following formula to calculate the circle’s area: ?...
Help with a c Program to compute the car insurance premium for a person based on...
Help with a c Program to compute the car insurance premium for a person based on their age and the number of tickets they have received. The following table explains how to perform the ticket computation: If Person's Age Is Then Insurance Cost Is Less than 21 $1500 + $250 x number of tickets From 21 through 24 $1200 + $250 x number of tickets 25 or older $1000 + $200 x number of tickets Print the person’s age, number...
Write a menu-driven program to test the three functions conver_tlength(), convert_width(), convert_volume() in a program. Program...
Write a menu-driven program to test the three functions conver_tlength(), convert_width(), convert_volume() in a program. Program should allow the user to select one of the options according to whether lengths, weights or volume are to be converted, read the volue to be converted and the units, and then call the appropriate function to carry out the conversion In unit out unit I C (inch to centimeter 1 in = 2.4 cm) F C (feet to centimeter 1 ft = 30.4...
Instructions: Submit to this page (from Part I) with your answers and the C++ program from...
Instructions: Submit to this page (from Part I) with your answers and the C++ program from Part II to the Blackboard. Type all answers in this page in RED. Part I Pointers to variables or places in RAM (Random Access Memory) are memory addresses – the address of the byte of memory to which the pointer is referring (or “referencing”). Some programming languages use pointers to increase efficiency, to make changes to variables indirectly, etc. In C++, if Z is...
C Program: Create a C program that prints a menu and takes user choices as input....
C Program: Create a C program that prints a menu and takes user choices as input. The user will make choices regarding different "geometric shapes" that will be printed to the screen. The specifications must be followed exactly, or else the input given in the script file may not match with the expected output. Important! Consider which control structures will work best for which aspect of the assignment. For example, which would be the best to use for a menu?...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT