Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

hello, i have already finished most of the work and i just needed some adjustments in my program( i have attached pictures of question as

hello, i have already finished most of the work and i just needed some adjustments in my program( i have attached pictures of question as well as my program). i just want the program to not print the whole calculator menu when we input 0 or 7 (depending on case)and just prompt directly for menu selection as the example in the question; and also make adjustments as necessary in the code. thank you!
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
In this project students 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 clear the result, display statistics, and exit the program. The project is designed to give students an opportunity to practice looping, type conversion, and data persistence. A Specification When the program starts it should display a menu, prompt the user to enter a menu option, and read a value: Current Result: 0.0 Calculator Menu 0. Exit Program 1. Addition 2. Subtraction 3. Multiplication 4. Division 5. Exponentiation 6. Logarithm 7. Display Average Enter Menu Selection: 1 If an option with operands (1-6) is selected, the program should prompt for and read floating point numbers as folliows: Enter first operand: 89.1 Enter second operand: 42 Once the two operands have been read, the result should be calculated and displayed, along with the menu: Current Result: 131.1 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. Exponentiation For exponentiation, the first operand should be used as the base and the second as the exponent, i.e.: If the first operand is 2 and the second is 4..24=16 Logarithm For logarithms, the first operand should be used as the base and the second as the yleid, Le.: If the first operand is 2 and the second is 4log24=2 (Hint: Use python math library) Displaying the Average As the program progresses, it should store the total of all results of calculation and the number of calculations. Note that this does not include the starting value of 0! The program should display the average of all. calculations as follows: Sum of calculations: 101.3 Number of calculations: 2 Average of calculations: 50.15 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! Extra Credit Using Results of Calculation You can earn 5% extra credit on this project by allowing the user to use the previous result in an operation. To add this feature, allow the user to enter the word "RESULT" in place of an operand; if the user does so, the program should replace this operand with the result of the previous calculation (or zero if this is the first calculation): Enter first operand: 89.1 Enter second operand: RESULT Sample Output Current Result: 0.0 Calculator Menu 0. Exit Program 1. Addition 2. Suberaction 3. Multiplication 4. Division 5. Exponentiation 6. Logarithm 7. Display Average Enter Menu Selection: 7 Error: No calculations yet to average! Enter Menu Selection: 1 Enter first operand: 0.5 Enter second operand: 2.5 Current Result: 2.0 Calculator Menu 0. Exit Program 1. Addition 2. Subtraction 3. Multiplication. 4. Division 5. Exponentiation 6. Logarithm 7. Display Average Enter Menu Selection: 6 Enter first operand: 2 Enter second operand: 0.5 Current Result: 1.0 Calculator Menu 0. Ext Program 1. Addition 2. Subtraction 3. Multiplication 4. Division 5. Exponentiation 6. Logarithm 7. Display Average Enter Menu Selection: 7 Sum of calculations: 2.75 Number of calculations: 3 Average of calculations: 0.92 6 Lab 3: Scientific Calculator Enter Menu Selection: 10 Error: Invalid selection! Enter Menu Selection: 0 Thanks for using this calculator. Goodbye! while True > if (i==7)> if no>0 print(Error:Invalidselection!)if(i7): print('Enter first operand:' , end=" "') uinput_first = float(input()) print ('Enter second operand:', end=""') uinput_second = float(input()) r= uinput_first*tuinput_second print('Current Result:', r ) r+=r sum = sum +r no = no +1 continue

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Database Administration The Essential Reference

Authors: Brian Laskey, David Kreines

1st Edition

1565925165, 978-1565925168

More Books

Students also viewed these Databases questions