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++ 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...
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...
Write a program in c++, with at least four functions, including main, which must do the...
Write a program in c++, with at least four functions, including main, which must do the following: Ask user whether they want to encode or decode a message – if no, then terminate Take the input string from the user, store it in dynamic memory (use new) As appropriate, encode or decode the message using Rot13. Output the encoded/decoded message Delete the input string from dynamic memory (use delete) Input will be a string of no more than 25 characters....
In C++, develop a menu program which reads in data from 4 different input files -...
In C++, develop a menu program which reads in data from 4 different input files - appetizers, entrees, desserts, and drinks. Then, record the item information ordered by the customer for each item selected. When finished, display all items ordered to the screen with the subtotal, tax (10% for easy math), and the total. Be sure to get tip as well. Then, ensure enough payment was received before generating an output file receipt which can be printed off. Use functions...
C program. librarys that are in use; stdio.h, stdlib.h, time.h, stddef.h, ctype.h, math.h, string.h. Need to...
C program. librarys that are in use; stdio.h, stdlib.h, time.h, stddef.h, ctype.h, math.h, string.h. Need to rewrite the functions linked in the code: "return add_move_lib ( board, col, colour ) ;" "return board_full_lib ( board ) ;" "return display_board_lib ( board ) ; // TASKS // board_full() display_board() add_move() // adds a token of the given value (1 or 2) to the board at the // given column (col between 1 and COLS inclusive) // Returns 0 if successful, -1...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT