Question: You will build a scientific calculator on the command line. The program will display a menu of options which includes several arithmetic operations as well
You will build a scientific calculator on the command line. The program will display a menu of options which includes several arithmetic operations as well as options to display statistics and exit the program. The project is designed to give you an opportunity to practice looping, type conversion, and data persistence.
When the program starts it should display a menu, prompt the user to enter a menu option, and read values:
Current Result:
Calculator Menu
Exit Program
Addition
Subtraction
Multiplication
Division
Exponentiation
Logarithm
Display Average
Enter Menu Selection:
When an option with operands is selected, the program should prompt for and read floating point numbers as follows:
Enter first operand:
Enter second operand:
Once the two operands have been read, the result should be calculated and displayed, along with the menu:
Current Result:
Calculator Menu
Operational Behavior
This calculator includes multiple behaviors that are unique depending on the input and operation specified; they are detailed in this section. Use Python's math library.
Exponentiation
For exponentiation, the first operand should be used as the base and the second as the exponent ie: If the first operand is and the second is :
Logarithm
For exponentiation, the first operand should be used as the base and the second as the exponent ie: If the first operand is and the second is : log
Displaying the Average
As the program progresses, it should store the total of all results of calculation and the number of calculations. Not that this does NOT include the starting value of The program should display the average of all calculations as such:
Sum of calculations:
Number of calculations:
Average of calculations:
Note that the average calculation should show a maximum of two decimal places. The program should immediately prompt the user for the next menu option without redisplaying the menu
If no calculations have been performed, this message should be displayed:
Error: no calculations yet to average!
Assumptions and Notes
If the menu option is invalid, output: "Invalid selection." without displaying the menu again. This menu option will be an integer, but not necessarily valid.
If the operands are invalid ie not applicable for certain operations see below output: Error: invalid input! without displaying the menu again no operation is completed
If the operand is RESULT, use the result of the previous calculation for that operand.
Certain operations have limitations on their inputs such as division: ab b so ensure that this is accounted for in your program.
Sample Submission Output
Example:
Current Result:
Calculator Menu
Exit Program
Addition
Subtraction
Multiplication
Division
Exponentiation
Logarithm
Display Average
Enter Menu Selection:
Error: No calculations yet to average!
Enter Menu Selection:
Enter first operand:
Enter second operand:
Current Result:
Calculator Menu
Exit Program
Addition
Subtraction
Multiplication
Division
Exponentiation
Logarithm
Display Average
Enter Menu Selection:
Enter first operand:
Enter second operand:
Current Result:
Calculator Menu
Exit Program
Addition
Subtraction
Multiplication
Division
Exponentiation
Logarithm
Display Average
Enter Menu Selection:
Enter first operand:
Enter second operand:
Current Result:
Calculator Menu
Exit Program
Addition
Subtraction
Multiplication
Division
Exponentiation
Logarithm
Display Average
Enter Menu Selection:
Sum of calculations:
Number of calculations:
Average of calculations:
Enter Menu Selection:
Error: Invalid selection!
Enter Menu Selection:
Thanks for using this calculator. Goodbye!
PLEASE MAKE SURE THE CODE IS RIGHT BECAUSE I KEEP GETTING WRONG CODE!!
ALSO MAKE SURE THAT I CAN COPY AND PAYSTE YOUR CODE.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
