Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

Assignment4 Write a program that asks a user to enter a starting value. Then the program will ask for an operation to perform on that number. The available operations are add, subtract, multiply, and...

1 answer below »
Assignment4
Write a program that asks a user to enter a starting value. Then the program will ask for an operation to perform on that number. The available operations are add, subtract, multiply, and division. The program will make sure a valid operation is selected. If there is not a valid operation chosen, then the program will notify the user and keep asking. When a valid operation is chosen then the user is asked to enter a number to perform the operation.The result of the operation is output to the screen and the user is prompted to enter the next operation to perform on the result followed by the value to use. The program will continue until a sentinel value of -999 is input.
Below is the input/output that you are to use.
Enter your starting number: -157
Enter A for Add, S for Subtract, M for multiply, or D for Divide to perform on -157 or enter -999 to end: add
So
y, ‘add’ is not a valid operation. Try Again!
Enter A for Add, S for Subtract, M for multiply, or D for Divide to perform on -157 or enter -999 to end: Add
So
y, ‘Add’ is not a valid operation. Try Again!
Enter A for Add, S for Subtract, M for multiply, or D for Divide to perform on -157 or enter -999 to end: A
Add -157 with what value: 357
The result is 200
Enter A for Add, S for Subtract, M for multiply, or D for Divide to perform on 200 or enter -999 to end: divide
So
y, ‘divide’ is not a valid operation. Try Again!
Enter A for Add, S for Subtract, M for multiply, or D for Divide to perform on 200 or enter -999 to end: Divide
Divide 200 with what value: 100
The result is 2
Enter A for Add, S for Subtract, M for multiply, or D for Divide to perform on 200 or enter -999 to end:-999
Program ended with a result of 2
Comment your source code and describe your code to someone who may be viewing it for the first time.
PLACE SCREEN SHOTS OF THE PYTHON CODE AND ALL I/O BELOW.
Answered 10 days After Mar 13, 2021

Solution

Devanshu answered on Mar 23 2021
142 Votes
Assignment4
Write a program that asks a user to enter a starting value. Then the program will ask for an operation to perform on that number. The available operations are add, subtract, multiply, and division. The program will make sure a valid operation is selected. If there is not a valid operation chosen, then the program will notify the user and keep asking. When a valid operation is chosen then the user is asked to enter a number to perform the operation.The result of the operation is output to the screen and the user is prompted to enter the next operation to perform on the result followed by the value to use. The program will continue until a sentinel value of -999 is input.
Below is the input/output that you are to use.
Enter your starting number: -157
Enter A for Add, S for Subtract, M for multiply, or D for Divide to perform on -157 or enter -999 to end: add
So
y, ‘add’ is not a valid operation. Try Again!
Enter A for Add, S for Subtract, M for multiply, or D for Divide to perform on -157 or enter -999 to end: Add
So
y, ‘Add’ is not a valid operation. Try Again!
Enter A for Add, S for Subtract, M for multiply, or D for Divide to perform on -157 or enter -999 to end: A
Add -157 with what value: 357
The result is 200
Enter A for Add, S for Subtract, M for multiply, or D for Divide to perform on 200 or enter -999 to end:...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here