Part 1 - Create a header comment with the title of this program, your name, and the date. Part 2 (Taking in user input) Part 2 Ask the user for two numbers. You can assume that the user will always give two positive integer numbers or "DONE". Prompt the user for an operand, the accepted operands are 11 1 1

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter5: Looping
Section: Chapter Questions
Problem 14E: In Chapter 4, you created a program that generates a random number, allows a user to guess it, and...
icon
Related questions
Question

Can you solve this problem using Python? Thanks.

Project4
The goal of this activity is to create a calculator that relies on simple arithmetic to
perform more complex calculations.
Part 1 - Create a header comment with the title of this program, your name, and the date.
Part 2 (Taking in user input)
Part 2 Ask the user for two numbers. You can assume that the user will always give two
positive integer numbers or "DONE". Prompt the user for an operand, the accepted operands are
+, -, /, and * for addition, subtraction, division, and multiplication respectively.
Anything else excluding “DONE” should be considered invalid. Continue to prompt the user for
values, performing the appropriate calculations until "DONE" is entered for any of the values.
Once "DONE" is entered as any of the three values the program should terminate.
Ex:
What is the first number: 7
What is the second number: 7
What operation: +
7 + 7 = 14
What is the first number: 6
What is the second number: 4
What operation: DONE
|
What is the first number: 7
What is the second number: 7
What operation: **
Invalid operand
What is the first number: 7
What is the second number: 3
What operation: %
Invalid operand
What is the first number: DONE
What is the second number: 8
What operation: DONE
>
Part 3 (Calculations)
3A(Addition):
increment the first value by the second value. In this section, you CANNOT simply add
the first value to the second, instead you must increment the number by 1 each time.
Ex:
4+1
+1
O +1
O +1
O +1
Print the output in the following format:
What is the first number: 6
What is the second number: 7
What operation:
6 + 7 = 13
4+5 =
3B(Subtraction):
decrement the first value by the second value. In this section, you CANNOT simply
subtract the first value to the second, instead you must decrement the number by 1 each time.
Ex:
● 4-5=
O 4-1
O -1
O -1
O -1
O -1
Print the output in the following format:
What is the first number: 7
What is the second number: 12
What operation:
7- 12 = -5
3C(Multiplication):
increment the first value by the second value. In this section, you CANNOT simply
multiply the first value to the second, instead you must increment the number using addition
only. (You do not need to increment by 1 each time)
Ex:
Ex:
● 4*3 =
O 0+4
O +4
O +4
Print the output in the following format:
What is the first number: 6
What is the second number: 123
What operation: *
6 123 = 738
oo
3D(Division):
decrement the first value by the second value. In this section, you CANNOT simply
divide the first value to the second, instead you must decrement the number using subtraction
only. Return both the quotient and the remainder.
● 4/2=
Note: Watch out for edge cases (check test cases for a hint).
Ex: 1
Print the output in the following format:
What is the first number: 47
What is the second number: 3
What operation: /
47 / 3 = 15 with a remainder of 2
Ex: 2
Example test case:
What is the first number: 6
What is the second number: 9
What operation: +
6 + 9 = 15
What is the first number: 40
What is the second number: 3
What operation: /
40/3 = 13 with a remainder of 1
What is the first number: 13
What is the second number: 3
What operation: -
13 - 3 = 10
What is the first number: DONE
What is the second number: 3
What operation: -
> |
O 4-2
O -2
What is the first number: 50
What
is the second number: 10
What operation: /
50 / 10 = 5 with
What
is
the
first number: 56
What
is the second number: 7
What operation: /
56 / 7 = 8 with
is
the
first number: 80
is the second number: 10
Ex: 3
What is
What
is
What
What
What operation:
80 10 90
is
the
first number: 90
is the second number: DONE
What
What
What operation: %
|
is
is
What operation: +
40+2 = 42
is
is
is
is
a remainder of 0
a remainder of 0
+
What
the first number: 12
What
the second number: 5
/
What operation:
12 / 5 = 2 with a remainder of 2
What
is
the
first number: 76
What
is
the second number: 0
What operation: /
Divide by zero error
What
What
What operation: *
129 108
the first number: 40
the second number: 2
What
What
What operation: %
the
first
number: 12
the second number: 9
the first number: DONE
the second number: 7
Transcribed Image Text:Project4 The goal of this activity is to create a calculator that relies on simple arithmetic to perform more complex calculations. Part 1 - Create a header comment with the title of this program, your name, and the date. Part 2 (Taking in user input) Part 2 Ask the user for two numbers. You can assume that the user will always give two positive integer numbers or "DONE". Prompt the user for an operand, the accepted operands are +, -, /, and * for addition, subtraction, division, and multiplication respectively. Anything else excluding “DONE” should be considered invalid. Continue to prompt the user for values, performing the appropriate calculations until "DONE" is entered for any of the values. Once "DONE" is entered as any of the three values the program should terminate. Ex: What is the first number: 7 What is the second number: 7 What operation: + 7 + 7 = 14 What is the first number: 6 What is the second number: 4 What operation: DONE | What is the first number: 7 What is the second number: 7 What operation: ** Invalid operand What is the first number: 7 What is the second number: 3 What operation: % Invalid operand What is the first number: DONE What is the second number: 8 What operation: DONE > Part 3 (Calculations) 3A(Addition): increment the first value by the second value. In this section, you CANNOT simply add the first value to the second, instead you must increment the number by 1 each time. Ex: 4+1 +1 O +1 O +1 O +1 Print the output in the following format: What is the first number: 6 What is the second number: 7 What operation: 6 + 7 = 13 4+5 = 3B(Subtraction): decrement the first value by the second value. In this section, you CANNOT simply subtract the first value to the second, instead you must decrement the number by 1 each time. Ex: ● 4-5= O 4-1 O -1 O -1 O -1 O -1 Print the output in the following format: What is the first number: 7 What is the second number: 12 What operation: 7- 12 = -5 3C(Multiplication): increment the first value by the second value. In this section, you CANNOT simply multiply the first value to the second, instead you must increment the number using addition only. (You do not need to increment by 1 each time) Ex: Ex: ● 4*3 = O 0+4 O +4 O +4 Print the output in the following format: What is the first number: 6 What is the second number: 123 What operation: * 6 123 = 738 oo 3D(Division): decrement the first value by the second value. In this section, you CANNOT simply divide the first value to the second, instead you must decrement the number using subtraction only. Return both the quotient and the remainder. ● 4/2= Note: Watch out for edge cases (check test cases for a hint). Ex: 1 Print the output in the following format: What is the first number: 47 What is the second number: 3 What operation: / 47 / 3 = 15 with a remainder of 2 Ex: 2 Example test case: What is the first number: 6 What is the second number: 9 What operation: + 6 + 9 = 15 What is the first number: 40 What is the second number: 3 What operation: / 40/3 = 13 with a remainder of 1 What is the first number: 13 What is the second number: 3 What operation: - 13 - 3 = 10 What is the first number: DONE What is the second number: 3 What operation: - > | O 4-2 O -2 What is the first number: 50 What is the second number: 10 What operation: / 50 / 10 = 5 with What is the first number: 56 What is the second number: 7 What operation: / 56 / 7 = 8 with is the first number: 80 is the second number: 10 Ex: 3 What is What is What What What operation: 80 10 90 is the first number: 90 is the second number: DONE What What What operation: % | is is What operation: + 40+2 = 42 is is is is a remainder of 0 a remainder of 0 + What the first number: 12 What the second number: 5 / What operation: 12 / 5 = 2 with a remainder of 2 What is the first number: 76 What is the second number: 0 What operation: / Divide by zero error What What What operation: * 129 108 the first number: 40 the second number: 2 What What What operation: % the first number: 12 the second number: 9 the first number: DONE the second number: 7
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

When I input "DONE", how will I do like example shown in image?

Thanks

 

What is the first number: 6
What is the second number: 9
What operation:
6 + 9 = 15
What is the first number: 40
What is the second number: 3
What operation: /
40 / 3 = 13 with a remainder of 1
What is the first number: 13
What is the second number: 3
What operation:
13 3 10
+
What is the first number: DONE
What is the second number: 3
What operation:
>
Transcribed Image Text:What is the first number: 6 What is the second number: 9 What operation: 6 + 9 = 15 What is the first number: 40 What is the second number: 3 What operation: / 40 / 3 = 13 with a remainder of 1 What is the first number: 13 What is the second number: 3 What operation: 13 3 10 + What is the first number: DONE What is the second number: 3 What operation: >
24 A
File Edit Selection View Go Run Terminal Help
ΘΟΔΟ
Workspace Trust
Project3_Zhang.py
Project4_Zhang.py X
C: > Users > junji > OneDrive > Desktop > miscellaneous > Project4_Zhang.py > ...
1 b=0
2
while(b!=1):
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
BARHEE44278
18
19
20
21
22
23
25
26
d1=(input("What is the first number : "))
d2=(input("What is the second number : "))
op=input("What operation: ")
if op=='+' or op=='*' or op=='-':
if op=='+':
ans-int(d1)+int (d2)
if op=='-':
ans-int(d1)-int(d2)
if op== '*':
ans-int(d1) *int(d2)
print (str(d1)+op+str(d2)+"="+str(ans))
elif op=='/' :
if d2==0:
55°F
Clear
else:
print("Divide by zero error")
ans-int(int (d1)/int (d2))
rem=int (d1) %int (d2)
print(str(d1)+op+str(d2)+"="+str(ans)+" with a remainder of "+str(rem))
elif op=="DONE":
else:
b=1
quit ()
-elif-d1=="DONE" or d2=="DONE":
b=1
quit()
print("Invalid operand")
PROBLEMS OUTPUT DEBUG CONSOLE TERMINAL JUPYTER
What is the first number : DONE
What is the second number : 3
What operation:
Traceback (most recent call last):
File "c:\Users\junji\OneDrive\Desktop\miscellaneous\Project4_Zhang.py", line 10, in <module>
ans-int(d1)-int (d2)
ValueError: invalid literal for int() with base 10: 'DONE'
PS C:\Users\junji>
Project4_Zhang.py - Visual Studio Code
H
O
Ln 21, Col 1 (114 selected) Spaces: 4
VO
UTF-8
I
A
08
Python + ✓
0
4))) O
M
X
...
CRLF Python 3.10.7 64-bit (microsoft store) Q
7:42 PM
10/2/2022
Transcribed Image Text:24 A File Edit Selection View Go Run Terminal Help ΘΟΔΟ Workspace Trust Project3_Zhang.py Project4_Zhang.py X C: > Users > junji > OneDrive > Desktop > miscellaneous > Project4_Zhang.py > ... 1 b=0 2 while(b!=1): 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 BARHEE44278 18 19 20 21 22 23 25 26 d1=(input("What is the first number : ")) d2=(input("What is the second number : ")) op=input("What operation: ") if op=='+' or op=='*' or op=='-': if op=='+': ans-int(d1)+int (d2) if op=='-': ans-int(d1)-int(d2) if op== '*': ans-int(d1) *int(d2) print (str(d1)+op+str(d2)+"="+str(ans)) elif op=='/' : if d2==0: 55°F Clear else: print("Divide by zero error") ans-int(int (d1)/int (d2)) rem=int (d1) %int (d2) print(str(d1)+op+str(d2)+"="+str(ans)+" with a remainder of "+str(rem)) elif op=="DONE": else: b=1 quit () -elif-d1=="DONE" or d2=="DONE": b=1 quit() print("Invalid operand") PROBLEMS OUTPUT DEBUG CONSOLE TERMINAL JUPYTER What is the first number : DONE What is the second number : 3 What operation: Traceback (most recent call last): File "c:\Users\junji\OneDrive\Desktop\miscellaneous\Project4_Zhang.py", line 10, in <module> ans-int(d1)-int (d2) ValueError: invalid literal for int() with base 10: 'DONE' PS C:\Users\junji> Project4_Zhang.py - Visual Studio Code H O Ln 21, Col 1 (114 selected) Spaces: 4 VO UTF-8 I A 08 Python + ✓ 0 4))) O M X ... CRLF Python 3.10.7 64-bit (microsoft store) Q 7:42 PM 10/2/2022
Solution
Bartleby Expert
SEE SOLUTION
Follow-up Question

I have a question. When I want to input "DONE" in inputing number part like  below:

What is the first number: DONE

or

What is the second number: DONE

How will I do that? Thanks. 

% 4 A
File Edit Selection View Go Run Terminal Help
Workspace Trust
→ Project3_Zhang.py
Project4_Zhang.py X
C: > Users > junji > OneDrive > Desktop > miscellaneous > Project4_Zhang.py > ...
1
b=0
2
3
4
5
6
7
8
9
Ⓒ⁰A0
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
while(b!=1):
d1=int (input ("What is the first number : "))
d2=int (input ("What is the second number : "))
op=input("What operation: ")
if op=='+' or op=='*' or op=='-':
if op=='+':
ans=d1+d2
if op=='-':
56°F
Mostly clear
ans=d1-d2
if op=='*':
ans=d1*d2
print (str(d1)+op+str(d2)+"="+str(ans))
elif op=='/' :
if d2==0:print("Divide by zero error")
else:
else:
ans-int (d1/d2)
rem=d1%d2
elif op=="DONE":
print (str(d1) +op+str(d2)+"="+str(ans)+" with a remainder of "+str(rem))
b=1
quit()
print("Invalid operand")
PROBLEMS OUTPUT DEBUG CONSOLE TERMINAL JUPYTER
Project4_Zhang.py - Visual Studio Code
40/3=13 with a remainder of 1
What is the first number: 13
What is the second number : 3
What operation:
13-3=10
What is the first number : DONE
Traceback (most recent call last):
File "c:\Users\junji\OneDrive\Desktop\miscellaneous\Project4_Zhang.py", line 3, in <module>
d1=int (input("What is the first number : "))
ValueError: invalid_literal for int() with base 10: 'DONE'
PS C:\Users\junji> [
H
is
■
Ln 8, Col 22 Spaces: 4
UTF-8
08
US 01 LOGIN PAGE
Python + ✓
0
$
☐ Û
8
X
...
CRLF Python 3.10.7 64-bit (microsoft store) o
6:59 PM
10/3/2022
Transcribed Image Text:% 4 A File Edit Selection View Go Run Terminal Help Workspace Trust → Project3_Zhang.py Project4_Zhang.py X C: > Users > junji > OneDrive > Desktop > miscellaneous > Project4_Zhang.py > ... 1 b=0 2 3 4 5 6 7 8 9 Ⓒ⁰A0 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 while(b!=1): d1=int (input ("What is the first number : ")) d2=int (input ("What is the second number : ")) op=input("What operation: ") if op=='+' or op=='*' or op=='-': if op=='+': ans=d1+d2 if op=='-': 56°F Mostly clear ans=d1-d2 if op=='*': ans=d1*d2 print (str(d1)+op+str(d2)+"="+str(ans)) elif op=='/' : if d2==0:print("Divide by zero error") else: else: ans-int (d1/d2) rem=d1%d2 elif op=="DONE": print (str(d1) +op+str(d2)+"="+str(ans)+" with a remainder of "+str(rem)) b=1 quit() print("Invalid operand") PROBLEMS OUTPUT DEBUG CONSOLE TERMINAL JUPYTER Project4_Zhang.py - Visual Studio Code 40/3=13 with a remainder of 1 What is the first number: 13 What is the second number : 3 What operation: 13-3=10 What is the first number : DONE Traceback (most recent call last): File "c:\Users\junji\OneDrive\Desktop\miscellaneous\Project4_Zhang.py", line 3, in <module> d1=int (input("What is the first number : ")) ValueError: invalid_literal for int() with base 10: 'DONE' PS C:\Users\junji> [ H is ■ Ln 8, Col 22 Spaces: 4 UTF-8 08 US 01 LOGIN PAGE Python + ✓ 0 $ ☐ Û 8 X ... CRLF Python 3.10.7 64-bit (microsoft store) o 6:59 PM 10/3/2022
Solution
Bartleby Expert
SEE SOLUTION
Follow-up Question

How to fix the error shown in the picture? Thanks.

% 4 A
File Edit Selection View Go Run Terminal Help
Workspace Trust
→ Project3_Zhang.py
Project4_Zhang.py X
C: > Users > junji > OneDrive > Desktop > miscellaneous > Project4_Zhang.py > ...
1
b=0
2
3
4
5
6
7
8
9
Ⓒ⁰A0
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
while(b!=1):
d1=int (input ("What is the first number : "))
d2=int (input ("What is the second number : "))
op=input("What operation: ")
if op=='+' or op=='*' or op=='-':
if op=='+':
ans=d1+d2
if op=='-':
56°F
Mostly clear
ans=d1-d2
if op=='*':
ans=d1*d2
print (str(d1)+op+str(d2)+"="+str(ans))
elif op=='/' :
if d2==0:print("Divide by zero error")
else:
else:
ans-int (d1/d2)
rem=d1%d2
elif op=="DONE":
print (str(d1) +op+str(d2)+"="+str(ans)+" with a remainder of "+str(rem))
b=1
quit()
print("Invalid operand")
PROBLEMS OUTPUT DEBUG CONSOLE TERMINAL JUPYTER
Project4_Zhang.py - Visual Studio Code
40/3=13 with a remainder of 1
What is the first number: 13
What is the second number : 3
What operation:
13-3=10
What is the first number : DONE
Traceback (most recent call last):
File "c:\Users\junji\OneDrive\Desktop\miscellaneous\Project4_Zhang.py", line 3, in <module>
d1=int (input("What is the first number : "))
ValueError: invalid_literal for int() with base 10: 'DONE'
PS C:\Users\junji> [
H
is
■
Ln 8, Col 22 Spaces: 4
UTF-8
08
US 01 LOGIN PAGE
Python + ✓
0
$
☐ Û
8
X
...
CRLF Python 3.10.7 64-bit (microsoft store) o
6:59 PM
10/3/2022
Transcribed Image Text:% 4 A File Edit Selection View Go Run Terminal Help Workspace Trust → Project3_Zhang.py Project4_Zhang.py X C: > Users > junji > OneDrive > Desktop > miscellaneous > Project4_Zhang.py > ... 1 b=0 2 3 4 5 6 7 8 9 Ⓒ⁰A0 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 while(b!=1): d1=int (input ("What is the first number : ")) d2=int (input ("What is the second number : ")) op=input("What operation: ") if op=='+' or op=='*' or op=='-': if op=='+': ans=d1+d2 if op=='-': 56°F Mostly clear ans=d1-d2 if op=='*': ans=d1*d2 print (str(d1)+op+str(d2)+"="+str(ans)) elif op=='/' : if d2==0:print("Divide by zero error") else: else: ans-int (d1/d2) rem=d1%d2 elif op=="DONE": print (str(d1) +op+str(d2)+"="+str(ans)+" with a remainder of "+str(rem)) b=1 quit() print("Invalid operand") PROBLEMS OUTPUT DEBUG CONSOLE TERMINAL JUPYTER Project4_Zhang.py - Visual Studio Code 40/3=13 with a remainder of 1 What is the first number: 13 What is the second number : 3 What operation: 13-3=10 What is the first number : DONE Traceback (most recent call last): File "c:\Users\junji\OneDrive\Desktop\miscellaneous\Project4_Zhang.py", line 3, in <module> d1=int (input("What is the first number : ")) ValueError: invalid_literal for int() with base 10: 'DONE' PS C:\Users\junji> [ H is ■ Ln 8, Col 22 Spaces: 4 UTF-8 08 US 01 LOGIN PAGE Python + ✓ 0 $ ☐ Û 8 X ... CRLF Python 3.10.7 64-bit (microsoft store) o 6:59 PM 10/3/2022
Solution
Bartleby Expert
SEE SOLUTION
Knowledge Booster
Function Arguments
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning