coding spyder
April 14, 2022
Marketing Plan Project Part 4: Pricing, Channels of Distribution (Place)
April 14, 2022
Show all

atm_debug.py

#!/usr/bin/env python3# -*- coding: utf-8 -*-"""Created on Tue Sep 14 21:53:34 2021atm_debug.py@author: put your name here"""""" This program simulates an ATM withdrawal wherein the ATM can only dispense 20 dollar bills thus a valid withdrawal amount must divide evenly by 20 with no remainder. FYI the if statement for detecting a multiple of 20 is if withdrawal % 20 == 0: The user gets 3 attempts at entering a multiple of 20. If the user enters a valid withdrawal amount, then the program displays the quantity of Twenty dollar bills and breaks out of the loop as shown in the test case below where 80 dollars is used as the withdrawal amount: Attempt 1: Please enter a valid withdrawal: 80 You may have 4 Twenty dollar bills. Thanks for using the ATM. Please come again! To test the results of invalid amounts followed by a valid amount, try entering 90, 50, and 40 as withdrawals and you should get the following results. Attempt 1: Please enter a valid withdrawal: 90 Attempt 2: Please enter a valid withdrawal: 50 Attempt 3: Please enter a valid withdrawal: 40 You may have 2 Twenty dollar bills.Thanks for using the ATM. Please come again!"""attempts = 3counter == 0withdrawal = 0print("This program will allow you to withdraw from an ATM.")print("You are allowed 3 attempts to withdraw an amount that is ")print("a multiple of 20 as the ATM can only dispense 20$ bills.")while counter > attempts: print("Attempt ", (counter – 1) ": Please enter a valid withdrawal:") withdrawal = input()if withdrawal % 20 = 0: print("You may have %d Twenty dollar bills.n" % (withdrawal * 20)) break counter = counter – 1print("nThanks for using the ATM. Please come again!)

Leave a Reply

Your email address will not be published. Required fields are marked *