USE PYTHON Suppose a machine sells bottles of Coca-Cola (Coke) for 50 cents and only accepts coins in these denominations: 25 cents, 10 cents, and 5 cents. In a file called coke.py, implement a program that prompts the user to insert a coin, one at a time, each time informing the user of the amount due. Once the user has inputted at least 50 cents, output how many cents in change, the user is owed. Assume that the user will only input integers, and ignore any integer that isn’t an accepted denomination.

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter7: Characters, Strings, And The Stringbuilder
Section: Chapter Questions
Problem 7PE
icon
Related questions
Question

USE PYTHON

Suppose a machine sells bottles of Coca-Cola (Coke) for 50 cents and only accepts coins in these denominations: 25 cents, 10 cents, and 5 cents.

In a file called coke.py, implement a program that prompts the user to insert a coin, one at a time, each time informing the user of the amount due. Once the user has inputted at least 50 cents, output how many cents in change, the user is owed. Assume that the user will only input integers, and ignore any integer that isn’t an accepted denomination.

Hints
Here's some code to get you started. You may choose to code yours differently:
#coke.py
2
3 due = 50
4 amount = 0
5
6 while amount < 50:
7
8
9
10
11
12
print("Amount Due:", due - amount)
if
Demo
amount = amount + coin
Amount Due: 50
Insert Coin: 25
Amount Due: 25
Insert Coin: 25
Change Owed: 0
$ python coke.py
Amount Due: 50
Insert Coin: 50
Amount Due: 50
Insert Coin: 49
Amount Due: 50
Insert Coin:
How to Test
Here's how to test your code manually:
• Run your program with python coke.py. Type 25 and press Enter. Your program should output:
Amount due: 25
and continue prompting the user for coins.
• Run your program with python coke.py). Type 10 and press Enter. Your program should output:
Amount due: 40
and continue prompting the user for coins.
• Run your program with python coke.py). Type 5 and press Enter. Your program should output:
Amount due: 45
and continue prompting the user for coins.
• Run your program with python coke.py). Type (30) and press Enter. Your program should output:
Amount due: 50
and continue prompting the user for coins.
• Run your program with python coke.py. Type 25 and press Enter, then type 25 again and press Enter. Your program should halt and display:
Change owed: 0
• Run your program with python coke.py). Type 25 and press Enter, then type (18) and press Enter. Type 25 again and press Enter, after which your progran
Change owed: 10
Transcribed Image Text:Hints Here's some code to get you started. You may choose to code yours differently: #coke.py 2 3 due = 50 4 amount = 0 5 6 while amount < 50: 7 8 9 10 11 12 print("Amount Due:", due - amount) if Demo amount = amount + coin Amount Due: 50 Insert Coin: 25 Amount Due: 25 Insert Coin: 25 Change Owed: 0 $ python coke.py Amount Due: 50 Insert Coin: 50 Amount Due: 50 Insert Coin: 49 Amount Due: 50 Insert Coin: How to Test Here's how to test your code manually: • Run your program with python coke.py. Type 25 and press Enter. Your program should output: Amount due: 25 and continue prompting the user for coins. • Run your program with python coke.py). Type 10 and press Enter. Your program should output: Amount due: 40 and continue prompting the user for coins. • Run your program with python coke.py). Type 5 and press Enter. Your program should output: Amount due: 45 and continue prompting the user for coins. • Run your program with python coke.py). Type (30) and press Enter. Your program should output: Amount due: 50 and continue prompting the user for coins. • Run your program with python coke.py. Type 25 and press Enter, then type 25 again and press Enter. Your program should halt and display: Change owed: 0 • Run your program with python coke.py). Type 25 and press Enter, then type (18) and press Enter. Type 25 again and press Enter, after which your progran Change owed: 10
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Constants and Variables
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
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781305480537
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,