Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Author is Songool Khan nter the operator. C., ., , /, o, ..): Enter input number A: 2 Enter input number B: 2 2+2- 4

image text in transcribed
Author is Songool Khan nter the operator. C., ., ", /, o, ..): Enter input number A: 2 Enter input number B: 2 2+2- 4 Ln: 20 Col: 0 In this assignment you are asked to add some enhancements to the simple calculator program you created in Assignment #1 (Al). The enlancements are: ore Nunbers (y?) y Enter the operator,., r*): Enter input nueber A: 2 Enter input number B: 2 Allow multiple calculations to be entered during one program session, rather than just one 2. 1. Check that the entered operator is valid (validation). If not, print an appropriate error message and re-prompt the user for another operator 3. Keep a running count of how many of each type of valid operations are entered during the session one for each of these: (+,, 4. Ln Record each valid calculation just before or after printing it in a "log" string 5. After the user indicates they have no more calculations during this session, print the number of each type of valid operations submitted and the log string. The contents of the log string must be printed so that each appears on its own separate line. The output should be almost the same as in Al, except that there will be eror and re-prompt messages while Truer op Cinput('Enter the operator, ....or ): ) a - intCinputC Enter irput nunber A: )) b -int(input( Enter input number 3: )) for the operator, and end-of-session messages showing the log and operator type counts Hints: 1. Use a "while' loop as the main program flow controller fale print("Error: Not valid.) Consider how the "while' loop will be controlled (ie. counter, sentry, or Boolean), how it can be used to determine when an operator is in error and has to be re-entered, and when the user wants to end the session (i.e. has no more calculations) The "log" string op - Cinput( Enter the operetor, (+, , ".,or *: ")) print(str(a).str(b).-", (ab)) print(str(a), ..' , str(b), '-', (a-b)) print(str(a), '", str(b) '-', (am), print(str(o)str(b).(a/b)) 2. elif op 3. can be built by concatenating each printed calculation to it. The string contents elif op calculation per line is printed Define separate counting variables for each of the operator types. 4. gin by trying to make sure you can successfully process one operation type, including the operator validation and operator count accumulation. Once that's done it should be a simple matter to replicate the logic for the other types 5. Be elif op print( Enror: Not walid) more- input"Morne Numbers (y) if more not in yesYesYES What and where to submit: 1. Submit by uploading a single file with the Python code to Blackboard breok 2. Name the submitted file: A2.py. For example: mary smith A2.py 3. Input a comment line as the first line that identifies the program, its purpose, and its author Comment lines start with the "W"character. Here's an example (substitute your name for "Mary Smith": op.count( op.count( op. countC' op. count op.count # Program name: mary-smith-A2py A2 Enhanced Calculator program Author Mary Smith /") 4. The file must execute from the command line, so include the following line of oode at the end of the program to ensure the program screen doesn't immediately erase when execution stops: 3581

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

Concepts of Database Management

Authors: Philip J. Pratt, Mary Z. Last

8th edition

1285427106, 978-1285427102

More Books

Students also viewed these Databases questions

Question

Provide examples of Dimensional Tables.

Answered: 1 week ago