1 result = 0 234567 3 while True: 8 9 10 11 12 13 print (result) user_input input ("Type in a quit or calculate: ") if user_input == 'quit': break operator = user_input[0] number int(user_input[1:]) if operator == '+': result result + number elif operator == '-': result = result - number

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter2: Using Data
Section: Chapter Questions
Problem 12RQ
icon
Related questions
Question

Could someone please help me modify this code? I don't know where is the problem with this code

1 result = 0
2
3 while True:
4
56789DHE
10
11
12
13
print (result)
user_input
=
input("Type in a quit or calculate: ")
if user_input == 'quit' :
break
=
operator
user_input[0]
number = int(user_input[1:])
if operator == '+'
result = result + number
elif operator == '_':
result = result - number
Compilation Failed
/usercode/file.cpp:6:22: warning: multi-character character constant [-Wmultichar]
if user_input == 'quit':
^~~~~~
/usercode/file.cpp:1:1: error: 'result' does not name a type
result = 0
^~~~~~
Transcribed Image Text:1 result = 0 2 3 while True: 4 56789DHE 10 11 12 13 print (result) user_input = input("Type in a quit or calculate: ") if user_input == 'quit' : break = operator user_input[0] number = int(user_input[1:]) if operator == '+' result = result + number elif operator == '_': result = result - number Compilation Failed /usercode/file.cpp:6:22: warning: multi-character character constant [-Wmultichar] if user_input == 'quit': ^~~~~~ /usercode/file.cpp:1:1: error: 'result' does not name a type result = 0 ^~~~~~
Expert Solution
steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Concept of memory addresses in pointers
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
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
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
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage