Penny=Penny - (Dime*10) # Printing the Dollars,Quarter, Dime, Penny if Penny <= 0: What's wrong with this expression? print('No change')
Penny=Penny - (Dime*10) # Printing the Dollars,Quarter, Dime, Penny if Penny <= 0: What's wrong with this expression? print('No change')
C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter8: Arrays And Strings
Section: Chapter Questions
Problem 10PE
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](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F1a505583-b612-46db-b366-0394caaecd49%2F75eab561-9d38-420e-afc7-41b05b8fec8d%2Fc79sjeq_processed.png&w=3840&q=75)
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
![](/static/compass_v2/shared-icons/check-mark.png)
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
This is a popular solution!
Step by step
Solved in 4 steps with 2 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Knowledge Booster
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
Recommended textbooks for you
![C++ Programming: From Problem Analysis to Program…](https://www.bartleby.com/isbn_cover_images/9781337102087/9781337102087_smallCoverImage.gif)
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
![C++ for Engineers and Scientists](https://www.bartleby.com/isbn_cover_images/9781133187844/9781133187844_smallCoverImage.gif)
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
![C++ Programming: From Problem Analysis to Program…](https://www.bartleby.com/isbn_cover_images/9781337102087/9781337102087_smallCoverImage.gif)
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
![C++ for Engineers and Scientists](https://www.bartleby.com/isbn_cover_images/9781133187844/9781133187844_smallCoverImage.gif)
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage