Project 3 Draft: ATM
Introduction
Your task for this project is to create a very simple ATM. The project is broken into three sections:
- Collect customer input
- Calculate the ending balance
- Display the results to the customer
Your final output should look like this:
Beginning Balance: 500.50
Deposit Amount: 200
Withdrawal Amount: 100
Collect Customer Input
If the action is Balance ‘B’, use a print balance function to return and print an account balance. You will need to write a function called printbalance.
- The opening balance has been assigned to a variable called
account_balanceequal to $500.25. Notice the use of the ‘float’ method in order to ensure that ‘account_balance’ is a float value. - Request the action to be taken on the account.
- Write a print balance function that returns the account balance.
- Create the action for selection ‘B’, Account Balance, to call the print balance function then print the account balance once the value is returned from the function.
- Test your code.
a. Create a prompt for the user to input the account action. There are three possible actions:
| Code | Action | Function |
|---|---|---|
D |
Deposit | deposit_amount |
W |
Withdrawal | withdrawal_amount |
B |
Account Balance | account_balance |
Create a function to print the account_balance, print the account actions and create the action for outputting the account balance outputting.
Input Information
The following data will be used as input in the test:
<code>userchoice = input (<span class="hljs-string">"What would you like to do?"</span>) userchoice = <span class="hljs-string">'B'</span> </code>
Output Information
<code>Your current balance: <span class="hljs-number">500.25</span></code>
Calculate the Balance – Deposit
If the action is Deposit ‘D’, use a deposit function to add funds to the account
- Write a function called `deposit`.
- Request from the user the amount to be deposited. This value should be stored in a variable called `deposit_amount`. Use both the `input` and `float` methods in order to ensure the `deposit_amount` is a float value.
- Calculate a new account balance.
- The calculation for depositing funds into the account is `account_balance = account_balance + deposit_amount`.
- Print the new account balance.
- You will need to define a function called
withdrawal. - Request from the user the amount to be withdrawn. This value should be stored in a variable called
withdrawal_amount. Use both theinputandfloatmethods in order to ensure thewithdrawal_amountis a float value - Ensure the withdrawal_amount is not greater than the account_balance.
- If the withdrawal_amount is greater than the `account_balance`, print the following message:
withdrawal_amountis greater than your account balance ofaccount_balanceEnsure you display the withdrawal amount and the account balance with the ‘$’ and two decimal points.
- If the withdrawal_amount is greater than the `account_balance`, print the following message:
- If the withdrawal amount is less than or equal to the
account_balancethen calculate a new account balance. - The calculation for withdrawing funds from the account is
account_balance = account_balance - withdrawal_amount - Print print the following message:Withdrawal amount was
withdrawal_amount, current balance isaccount_balance
Deposit Input
<code>userchoice = input (<span class="hljs-string">"What would you like to do?n"</span>) userchoice = <span class="hljs-string">'B'</span> deposit_amount = <span class="hljs-number">200</span> </code>
Deposit Output
<code>What would you like to do? How much would you like to deposit today? Deposit was $200, current balance is $700.25 </code>
Calculate the Balance – Withdrawal
If the action is Withdrawal ‘W’, use the withdrawal function to remove funds from the account
Hint – The formatter for a float value in Python is %f. With the formatter %.2f, you format the float to have 2 decimal places. For example:
print("Account balance: $%.2f" % account_balance)
Withdrawal Information
Withdraw Input
<code>userchoice = input (<span class="hljs-string">"What would you like to do?n"</span>) userchoice = <span class="hljs-string">'W'</span> withdrawal_amount = <span class="hljs-number">100</span> </code>
Withdraw Output
<code>What would you like to do? How much would you like to withdraw today? Withdrawal amount was $100, current balance is $600.25 </code>
ATM Summary
Your final function in the ATM Script is the Print the Customer summary as follows:
Final Input
<code>userchoice = input (<span class="hljs-string">"What would you like to do?n"</span>) userchoice = <span class="hljs-string">'Q'</span> </code>
Final Output
<code>What would you like to do? Thank you for banking with us. </code>
Two paragraphs on the below prompt:
II. Reflection – Applying Your Experience
Making mistakes when you learn to write code is common. It is part of learning. What is important is developing the skill of learning how to understand
your errors and then fix them (debugging). For this part of your final project, you will respond to the following:
A. Reflecting on your experience with this activity, explain the importance of knowing how and when to use and modify custom functions, inputs
(parameters) within functions, and functions to return the correct output. Support your response with examples from the activity of the types of
errors and your method for fixing them.


0 comments