Penny=Penny - (Dime*10) # Printing the Dollars,Quarter, Dime, Penny if Penny <= 0: What's wrong with this expression? print('No change')

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

What's wrong with line 18, 19 in the code in the screenshot attached. Attempting to check zero, or negative input by the user. Thanks

# Asking user input in pennies
1
>
Penny = int(input("Enter pennies: "))
>
3
# Finding the number of Dollars
> ullı Exti 4
O Sr
5
Dollars = Penny//100
# Calculating the remaining pennies
6
Penny=Penny - (Dollars*100)
# Finding the number of Quarters
8
Quarter = Penny//25
10
# Finding the number of Quarters
11
Penny=Penny - (Quarter*25)
12
# Finding the number of Dime
13
Dime = Penny//10
14
# Finding the number of
Quarters
Penny=Penny - (Dime*10)
# Printing the Dollars, Quarter, Dime, Penny
15
16
17
if Penny <= 0:
What's wrong with this expression?
18
19
print('No change')
20
21
gif (Dollars):
if (Dollars>1):
print("Dollars:", Dollars)
22
23
24
else:
25
print("Dollar:", Dollars)
26
27
Gif (Quarter):
Run:
Enter pennies: -9
Dollar: -1
Quarters: 3
Dime: 1
Pennies: 6
Process finished with exit code 0
Transcribed Image Text:# Asking user input in pennies 1 > Penny = int(input("Enter pennies: ")) > 3 # Finding the number of Dollars > ullı Exti 4 O Sr 5 Dollars = Penny//100 # Calculating the remaining pennies 6 Penny=Penny - (Dollars*100) # Finding the number of Quarters 8 Quarter = Penny//25 10 # Finding the number of Quarters 11 Penny=Penny - (Quarter*25) 12 # Finding the number of Dime 13 Dime = Penny//10 14 # Finding the number of Quarters Penny=Penny - (Dime*10) # Printing the Dollars, Quarter, Dime, Penny 15 16 17 if Penny <= 0: What's wrong with this expression? 18 19 print('No change') 20 21 gif (Dollars): if (Dollars>1): print("Dollars:", Dollars) 22 23 24 else: 25 print("Dollar:", Dollars) 26 27 Gif (Quarter): Run: Enter pennies: -9 Dollar: -1 Quarters: 3 Dime: 1 Pennies: 6 Process finished with exit code 0
Expert Solution
Step 1

Instead of checking the value in penny after the calculation of other variables you need to check this variable just after the input. After checking for an inappropriate value the program should give some error message and exit itself. The below provided program will cover all these aspects.

trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Program on Numbers
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
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education