Question

Use a switch statement to build a menu-driven calculator


ENGR 40 PROGRAMMING ASSIGNMENT MENU-DRIVEN CALCULATOR PROGRAM 


Use a switch statement to build a menu-driven calculator. Your program should ask the user to choose from a list of ten possible functions (square root, square, natural log, common log, e'x yx, 1/x, sin(x), cos(x), and tan(x). Each choice will correspond to an integer -example: (1) square root, (2) square, etec. Once the person has input a function choice then a switch statement will control the flow of the program- ie. the program will branch to the correct function and ask for the function's input. Most function choices will require a single user input while one (yx) will require two user inputs. For the trigonometric functions of sin(x), cos(x), and tan(x) the user will enter the input angle in degrees (though it will need to be converted to radians before using the C++ trig functions). 


User inputs should be bulletproofed against improper inputs (for example, the natural and common logarithm functions are not allowed to have inputs less than or equal to zero). The person using the program should continue to be prompted for function input until he/she enters valid value(s).


Demonstrate your program's operation to the instructor during a lab period (no hard copy submission for this assignment).

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

OUTPUT:-


1.For square root:
2.For square:
3.For natural log:
4.For common log:
5.For e^x:
6.For y^x:
7.For 1/x:
8.For sin(x):
9.For cos(x):
10.For tan(x):
11.Terminate the program:
Enter the choice:
1
Enter the no which we want to be a squareroot no:
5.2
The square root of this no=2.28035
1.For square root:
2.For square:
3.For natural log:
4.For common log:
5.For e^x:
6.For y^x:
7.For 1/x:
8.For sin(x):
9.For cos(x):
10.For tan(x):
11.Terminate the program:
Enter the choice:
2
Enter the no which we want to be a square no:
4.2
The square of this no=17.64
1.For square root:
2.For square:
3.For natural log:
4.For common log:
5.For e^x:
6.For y^x:
7.For 1/x:
8.For sin(x):
9.For cos(x):
10.For tan(x):
11.Terminate the program:
Enter the choice:
3
Enter the no for find natural log:
15
The natural log of this no=2.70805
1.For square root:
2.For square:
3.For natural log:
4.For common log:
5.For e^x:
6.For y^x:
7.For 1/x:
8.For sin(x):
9.For cos(x):
10.For tan(x):
11.Terminate the program:
Enter the choice:
4
Enter the no for find common log:
3
The common log of this no=0.477121
1.For square root:
2.For square:
3.For natural log:
4.For common log:
5.For e^x:
6.For y^x:
7.For 1/x:
8.For sin(x):
9.For cos(x):
10.For tan(x):
11.Terminate the program:
Enter the choice:
5
Enter the no for find e^x:
3
The exponent of this no=20.0855
1.For square root:
2.For square:
3.For natural log:
4.For common log:
5.For e^x:
6.For y^x:
7.For 1/x:
8.For sin(x):
9.For cos(x):
10.For tan(x):
11.Terminate the program:
Enter the choice:
6
Enter the no's for find y^x:
3 4
The result is=81
1.For square root:
2.For square:
3.For natural log:
4.For common log:
5.For e^x:
6.For y^x:
7.For 1/x:
8.For sin(x):
9.For cos(x):
10.For tan(x):
11.Terminate the program:
Enter the choice:
7
Enter the no's for find 1/x:
5
The result is=0.2
1.For square root:
2.For square:
3.For natural log:
4.For common log:
5.For e^x:
6.For y^x:
7.For 1/x:
8.For sin(x):
9.For cos(x):
10.For tan(x):
11.Terminate the program:
Enter the choice:
7
Enter the no's for find 1/x:
0
Enter value is equal zero:
Please enter the real value other than 0:
3
The result is=0.333333
1.For square root:
2.For square:
3.For natural log:
4.For common log:
5.For e^x:
6.For y^x:
7.For 1/x:
8.For sin(x):
9.For cos(x):
10.For tan(x):
11.Terminate the program:
Enter the choice:
8
Enter the degree value for find sin(x) :
90
The result is=1
1.For square root:
2.For square:
3.For natural log:
4.For common log:
5.For e^x:
6.For y^x:
7.For 1/x:
8.For sin(x):
9.For cos(x):
10.For tan(x):
11.Terminate the program:
Enter the choice:
9
Enter the degrre value for find cos(x) :
60
The result is=0.500001
1.For square root:
2.For square:
3.For natural log:
4.For common log:
5.For e^x:
6.For y^x:
7.For 1/x:
8.For sin(x):
9.For cos(x):
10.For tan(x):
11.Terminate the program:
Enter the choice:
10
Enter the degrre value for find tan(x) :
60
The result is=1.73205
1.For square root:
2.For square:
3.For natural log:
4.For common log:
5.For e^x:
6.For y^x:
7.For 1/x:
8.For sin(x):
9.For cos(x):
10.For tan(x):
11.Terminate the program:
Enter the choice:
11

Add a comment
Know the answer?
Add Answer to:
Use a switch statement to build a menu-driven calculator
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
  • Q2: Write a menu-driven C program using switch-case to calculate the following: 1. Area of circle...

    Q2: Write a menu-driven C program using switch-case to calculate the following: 1. Area of circle 2. Area of square 3. Area of rectangle The program should use the following functions properly: void displayMenu() //a function that will display the menu options to the user int getChoice() //a function that will input the user choice and returns it float calculate(int choice) //a function that reads the required inputs based on the user choice, and returns the area of the shape...

  • Please make program. Don't use cstdlib, iosstream, cmath, math.h I didn't learn about it. Only use...

    Please make program. Don't use cstdlib, iosstream, cmath, math.h I didn't learn about it. Only use for, while if switch function. I learned only those functions. Please comment. Thank you! c++ you can use Taylor-Maclaurin series 1. cos(0) 2. sin(O) 3. tan(e) 4. acos(x) asin(x) 6. atan(x) 5. Rules . • Make one C file for all code. • You cannot make functions, i.e. Implement every (above 6) in single (main) function with user asking to choose what they wants....

  • Please help me to do my assignment it should be python. Thank you Write a menu-driven...

    Please help me to do my assignment it should be python. Thank you Write a menu-driven program for Food Court. (You need to use functions!) Display the food menu to a user (Just show the 5 options' names and prices - No need to show the Combos or the details!) Ask the user what he/she wants and how many of it. (Check the user inputs) AND Use strip() function to strip your inputs. Keep asking the user until he/she chooses...

  • Create a menu-driven program (using the switch) that finds and displays areas of 3 different objects....

    Create a menu-driven program (using the switch) that finds and displays areas of 3 different objects. The menu should have the following 4 choices: 1 -- rectangle 2 -- circle 3 -- triangle 4 -- quit If the user selects choice 1, the program should find the area of a rectangle. rectangle area = length * width If the user selects choice 2, the program should find the area of a circle. circle area = PI * radius * radius...

  • Calculator Project

    AssignmentYou will be designing a calculator complete with user interface to take input from the user, process a response, and produce the output.Step 1: Present a menuFirst thing you should do is present a menu to the user when your program is first ran. Make sure that the operations match the numbers presented below, otherwise the graders won't be able to grade your program.1. Cartesian distance 2. Vector x matrix 3. Normalize 4. Quit Enter command:You will present the menu and wait for the user to input their...

  • Please use C++ and output have to look like that Create a menu driven C++ program...

    Please use C++ and output have to look like that Create a menu driven C++ program with functions. There must be four functions, calculating the size of area of circle, rectangle, triangle, and parallelogram. You are required to create those four functions and invoke them from the main program in order to reccive any credit. Please Submit: . A flowchart of your program with equations and expected results. 4 points) 2. Printout of your C++program with a heading comment, also...

  • Write a Program that has a menu with a  layout below, that asks the user if they...

    Write a Program that has a menu with a  layout below, that asks the user if they want to: 1. Converts from feet and inches to meter and centimeters 2. Converts from meter and centimeters to feet and inches 3. Quit the program The program should continue as long as the user asks it to. The program will use a switch statement for the menu option selection. Either a do loo or a do-while loop can be used for the overall...

  • Develop a flowchart and then write a menu-driven C++ program that uses several FUNCTIONS to solve...

    Develop a flowchart and then write a menu-driven C++ program that uses several FUNCTIONS to solve the following program. -Use Microsoft Visual C++ .NET 2010 Professional compiler using default compiler settings. -Use Microsoft Visio 2013 for developing your flowchart. -Adherence to the ANSI C++  required -Do not use <stdio.h> and <conio.h>. -Do not use any #define in your program. -No goto statements allowed. Upon execution of the program, the program displays a menu as shown below and the user is prompted to make a selection from the menu....

  • Requesting help with the following C Program: DESIGN and IMPLEMENT a menu driven program that uses...

    Requesting help with the following C Program: DESIGN and IMPLEMENT a menu driven program that uses the following menu and can perform all menu items: Enter a payroll record for one person Display all paycheck stubs Display total gross payroll from all pay records. Quit program The program will reuse the DATE struct from the previous assignment.  You should also copy in the functions relating to a DATE. The program will create a PAYRECORD struct with the following fields: typedef struct...

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
ADVERTISEMENT