Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Pls update the detailed code using python. Thanks The vending machine you wrote in the previous exercise (an example solution given below) can accept only

image text in transcribedimage text in transcribedPls update the detailed code using python. Thanks

The vending machine you wrote in the previous exercise (an example solution given below) can accept only one coin as the payment. If the coin is not enough, it rejects the coin and request the user to insert a new coin. \begin{tabular}{r|l} 1 & price =100 \\ 2 & coin_value = 0 \\ 3 & \\ 4 & print('Price:', price) \\ 5 & \\ 6 & while price > coin_value: \\ 7 & coin_value = int(input('Enter a coin:')) \\ 8 & print('You have entered:', coin_value) \\ 9 & print('Here is the product') \\ 10 & print('Your balance:', coin_value - price) \\ 11 & pring \end{tabular} Modify the code so that it can accumulate coins until there is enough to pay for the product. An example output is given below: \begin{tabular}{l|l} 1 & Price: 100 \\ 2 & Enter a coin: 20 \\ 3 & You have entered: 20 \\ 4 & Enter a coin: 50 \\ 5 & You have entered: 70 \\ 6 & Enter a coin: 50 \\ 7 & You have entered: 120 \\ 8 & Here is the product \\ 9 & Your balance: 20 \end{tabular} 9 see hint \begin{tabular}{l|l} 1 & \\ 2 & coin_sum =0 \\ 3 & \\ 4 & coin_sum = coin_sum + coin_value \\ 5 & \end{tabular}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Database Technology Edbt 88 International Conference On Extending Database Technology Venice Italy March 14 18 1988 Proceedings Lncs 303

Authors: Joachim W. Schmidt ,Stefano Ceri ,Michele Missikoff

1988th Edition

3540190740, 978-3540190745

More Books

Students also viewed these Databases questions

Question

What is the terminal value of a project? How is it calculated?

Answered: 1 week ago