-
Notifications
You must be signed in to change notification settings - Fork 205
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #423 from ishant025/main
Added ATM Interface
- Loading branch information
Showing
2 changed files
with
93 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Basic ATM Interface in Python | ||
|
||
def display_menu(): | ||
print("\nATM Menu") | ||
print("1. Check Balance") | ||
print("2. Deposit Money") | ||
print("3. Withdraw Money") | ||
print("4. Exit") | ||
|
||
|
||
def check_balance(balance): | ||
print(f"\nYour current balance is: ${balance}") | ||
|
||
|
||
def deposit_money(balance): | ||
amount = float(input("Enter amount to deposit: $")) | ||
if amount > 0: | ||
balance += amount | ||
print(f"${amount} deposited successfully.") | ||
else: | ||
print("Invalid deposit amount!") | ||
return balance | ||
|
||
|
||
def withdraw_money(balance): | ||
amount = float(input("Enter amount to withdraw: $")) | ||
if amount > 0 and amount <= balance: | ||
balance -= amount | ||
print(f"${amount} withdrawn successfully.") | ||
elif amount > balance: | ||
print("Insufficient funds!") | ||
else: | ||
print("Invalid withdrawal amount!") | ||
return balance | ||
|
||
|
||
def atm_interface(): | ||
balance = 5000.00 # Initial balance | ||
while True: | ||
display_menu() | ||
choice = input("\nEnter your choice (1-4): ") | ||
|
||
if choice == '1': | ||
check_balance(balance) | ||
elif choice == '2': | ||
balance = deposit_money(balance) | ||
elif choice == '3': | ||
balance = withdraw_money(balance) | ||
elif choice == '4': | ||
print("Thank you for using the ATM. Goodbye!") | ||
break | ||
else: | ||
print("Invalid choice! Please try again.") | ||
|
||
|
||
# Run the ATM interface | ||
atm_interface() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Basic ATM Interface | ||
|
||
### 🎯 **Goal** | ||
Here's a simple Basic ATM Interface project in Python. This project simulates an ATM where users can check their balance, deposit money, withdraw money, and exit. | ||
|
||
|
||
### 🚀 **How it works** | ||
1. The user is presented with a menu to check balance, deposit money, withdraw money, or exit. | ||
2. Based on the user's input: | ||
* Check Balance: Displays the current balance. | ||
* Deposit Money: Adds the entered amount to the current balance. | ||
* Withdraw Money: Subtracts the entered amount from the balance if there are sufficient funds. | ||
* Exit: Terminates the program. | ||
|
||
3. The program continues running until the user chooses to exit. | ||
|
||
### **Features** | ||
* Check Balance: See the current account balance. | ||
* Deposit Money: Add money to the account. | ||
* Withdraw Money: Take money from the account if the balance allows. | ||
* Exit: Quit the program. | ||
|
||
## 🔧 How to Run | ||
|
||
1. Clone the repository and navigate to the project folder: | ||
```bash | ||
git clone <repository-url> | ||
cd <project-folder> | ||
``` | ||
|
||
2. Install dependencies (if any) and then run the program: | ||
```bash | ||
python3 ATM.py | ||
``` | ||
--- | ||
|