Answered step by step
Verified Expert Solution
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
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 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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started