write a simple banking software program...
Here's an example of a simple banking software program:
```python
class BankAccount:
def __init__(self, account_number, balance=0):
self.account_number = account_number
self.balance = balance
def deposit(self, amount):
if amount > 0:
self.balance += amount
print(f"Deposit of {amount} successful.")
print(f"New Balance: {self.balance}")
else:
print("Invalid amount.")
def withdraw(self, amount):
if amount > 0 and amount <= self.balance:
self.balance -= amount
print(f"Withdrawal of {amount} successful.")
print(f"New Balance: {self.balance}")
else:
print("Insufficient balance.")
def check_balance(self):
print(f"Account Balance: {self.balance}")
def print_account_details(self):
print(f"Account Number: {self.account_number}")
print(f"Account Balance: {self.balance}")
def main():
account_number = input("Enter account number: ")
account = BankAccount(account_number)
while True:
print("\n1. Deposit")
print("2. Withdraw")
print("3. Check Balance")
print("4. Print Account Details")
print("5. Exit")
choice = input("Enter your choice (1-5): ")
if choice == "1":
amount = float(input("Enter deposit amount: "))
account.deposit(amount)
elif choice == "2":
amount = float(input("Enter withdrawal amount: "))
account.withdraw(amount)
elif choice == "3":
account.check_balance()
elif choice == "4":
account.print_account_details()
elif choice == "5":
break
else:
print("Invalid choice. Please try again.")
if __name__ == "__main__":
main()
```
This program defines a `BankAccount` class that represents a bank account. It has methods for depositing, withdrawing, checking the balance, and printing the account details. In the `main` function, the user is prompted to enter the account number, and then they can choose from various options like depositing, withdrawing, checking the balance, and printing the account details. The program keeps running until the user chooses to exit.
Comments
Post a Comment