Question: ATM Machine Some hints Format a floating point number as a string, to two decimal places: spam = 12.3456789 ham = '{:.2f}'.format(spam) # '12.35' Split

ATM Machine

Some hints

Format a floating point number as a string, to two decimal places:

spam = 12.3456789 ham = '{:.2f}'.format(spam) # '12.35'

Split a string into a list of strings, using whitespace as the delimiter:

spam = 'abc ijk xyz' ham = spam.split() # ['abc', 'ijk', 'xyz']

Exit a program:

exit()

What to do

Write a program that simulates the operations of the ATM. A user can perform these operations on the ATM:

Balance

Deposit

Withdraw

After completing an operation, the ATM asks the user if they want to perform another operation.

If the user enters N, the ATM exits.

If the user enters Y, the ATM waits for further input from the user.

To help you begin, some scaffold code has been provided. You can modify this scaffold code as much or as little as you want.

Please ensure that the code for your ATM program is written in the atm.py file.

The program

The program is run in the Terminal, and receives command line arguments like so:

$ python3 atm.py     

Example:

$ python3 atm.py John Smith 066 10344456 1000

Your program should store these five properties, and handle the cases where fewer than five properties are provided.

The ATM accepts these commands:

balance

deposit

withdraw

quit

All commands are case sensitive. The user will enter these commands in lower case.

For the following examples of program execution, all bolded text is input that is entered by the user.

Balance

A user can retrieve the balance from their account. The ATM shows the full name, BSB, account number and balance.

balance John Smith BSB: 466423 ACCNO: 23833432 BALANCE: 249.50

Deposit

A user can deposit money into their account. The ATM asks the user how many of each note ($50, $20, $10, $5) will be deposited. The user should enter a non-negative number beside each note. The ATM then updates the balance accordingly.

deposit How many 50's? 1 How many 20's? 0 How many 10's? 1 How many 5's? 1 SUCCESS: deposited $65.00 into your account

If the user enters an invalid (negative) number, the ATM prints an error message, like so:

deposit How many 50's? 1 How many 20's? 0 How many 10's? -1 How many 5's? 1 ERROR: Invalid input, specify a positive number

Withdraw

A user can withdraw money from their account. The ATM checks whether the user has enough money in their account, and updates the balance accordingly.

withdraw 200 SUCCESS: Withdrew 200.00 from account

If the amount to withdraw is greater than the balance in the account:

withdraw 500 ERROR: Unable to withdraw amount, amount requested is greater than balance.

If the amount to withdraw is negative:

withdraw -200 ERROR: Unable to withdraw amount, amount requested is invalid

Asking to continue

After an operation ends (either in SUCCESS or ERROR), the ATM asks the user if they want to continue using the ATM.

Do you want to continue? Y/N 

If the user enters N, the ATM prints Have a nice day! and exits.

Do you want to continue? Y/N N Have a nice day!

If the user enters Y, the ATM waits for further input from the user (as if the program was just started).

Quit

A user can quit using the ATM. The ATM prints Have a nice day! and exits.

quit Have a nice day!

Examples

Example 1: not enough arguments given to the program

ERROR: Not enough arguments supplied

Example 2: quit

quit Have a nice day!

Example 3: balance

balance J Smith BSB: 466423 ACCNO: 23833432 BALANCE: 500.00 Do you want to continue? Y/N N Have a nice day!

Example 4: balance, withdraw, balance

balance John Smith BSB: 466423 ACCNO: 23833432 BALANCE: 500.00 Do you want to continue? Y/N Y withdraw 250.50 SUCCESS: Withdrew 250.50 from account Do you want to continue? Y/N Y balance John Smith BSB: 466423 ACCNO: 23833432 BALANCE: 249.50 Do you want to continue? Y/N N Have a nice day!

Example 5: deposit, balance

deposit How many 50's? 2 How many 20's? 0 How many 10's? 0 How many 5's? 1 SUCCESS: deposited 105.00 into your account Do you want to continue? Y/N Y balance John Smith BSB: 466423 ACCNO: 23833432 BALANCE: 605.00 Do you want to continue? Y/N N Have a nice day!

ATM Machine Some hints Format a floating point number as a string,

i have no idea how to start it, so just writing the beginning of everything, can anyone help me ? thanks!

1 import sys 2 3 ERRORERROR ' 4 SUCCESS'SUCCESS: 6 first-None 7 lastNone 8 bsb None 9 accnoNone 10 balance None 11 NOTES[50, 20, 10, 5,]

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!