0% found this document useful (0 votes)
6 views2 pages

Cca Me

The document outlines a simple object-oriented banking system implemented in Python, featuring an Account class for managing individual accounts and a BankSystem class for handling account operations. Users can create accounts, deposit and withdraw funds, check balances, and close accounts through a menu-driven interface. The system ensures unique account numbers and provides feedback on transactions and account status.

Uploaded by

karanthvishnu1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views2 pages

Cca Me

The document outlines a simple object-oriented banking system implemented in Python, featuring an Account class for managing individual accounts and a BankSystem class for handling account operations. Users can create accounts, deposit and withdraw funds, check balances, and close accounts through a menu-driven interface. The system ensures unique account numbers and provides feedback on transactions and account status.

Uploaded by

karanthvishnu1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

class Account:

next_account_number = 1001 # Class variable

def __init__(self, name, balance):


self.acc_no = str(Account.next_account_number)
self.name = name
self.balance = balance
Account.next_account_number += 1

def deposit(self, amount):


self.balance += amount
print(f"₹₹{amount} deposited. New balance: ₹{self.balance}\n")

def withdraw(self, amount):


if amount <= self.balance:
self.balance -= amount
print(f"₹₹{amount} withdrawn. Remaining balance: ₹{self.balance}\n")
else:
print("❌ Insufficient balance!\n")

def check_balance(self):
print(f"₹Current balance for account {self.acc_no} is ₹{self.balance}\n")

class BankSystem:
def __init__(self):
self.accounts = []

def create_account(self):
name = input("Enter Account Holder Name: ")
balance = float(input("Enter Initial Deposit: "))
acc = Account(name, balance)
self.accounts.append(acc)
print(f"✅ Account created successfully! Your Account Number is:
{acc.acc_no}\n")

def find_account(self, acc_no):


for acc in self.accounts:
if acc.acc_no == acc_no:
return acc
return None

def deposit(self):
acc_no = input("Enter Account Number for Deposit: ")
acc = self.find_account(acc_no)
if acc:
amount = float(input("Enter amount to deposit: "))
acc.deposit(amount)
else:
print("❌ Account not found!\n")

def withdraw(self):
acc_no = input("Enter Account Number for Withdrawal: ")
acc = self.find_account(acc_no)
if acc:
amount = float(input("Enter amount to withdraw: "))
acc.withdraw(amount)
else:
print("❌ Account not found!\n")
def check_balance(self):
acc_no = input("Enter Account Number to Check Balance: ")
acc = self.find_account(acc_no)
if acc:
acc.check_balance()
else:
print("❌ Account not found!\n")

def close_account(self):
acc_no = input("Enter Account Number to Close: ")
acc = self.find_account(acc_no)
if acc:
self.accounts.remove(acc)
print(f"✅ Account {acc_no} closed successfully.\n")
else:
print("❌ Account not found!\n")

def run(self):
while True:
print("===== BANKING SYSTEM MENU =====")
print("1. Create Account")
print("2. Deposit")
print("3. Withdraw")
print("4. Check Balance")
print("5. Close Account")
print("6. Exit")
choice = input("Enter your choice (1-6): ")

if choice == '1':
self.create_account()
elif choice == '2':
self.deposit()
elif choice == '3':
self.withdraw()
elif choice == '4':
self.check_balance()
elif choice == '5':
self.close_account()
elif choice == '6':
print("👋 Exiting... Thank you for using our banking system.")
break
else:
print("❌ Invalid choice! Please try again.\n")

# Run the OOP-based banking system


if __name__ == "__main__":
bank_app = BankSystem()
bank_app.run()

You might also like