Main function to run the Python Banking System.
()
| 131 | |
| 132 | |
| 133 | def main(): |
| 134 | """ |
| 135 | Main function to run the Python Banking System. |
| 136 | """ |
| 137 | bank = Bank() |
| 138 | |
| 139 | while True: |
| 140 | print("\nPython Banking System") |
| 141 | print("1. Create Account") |
| 142 | print("2. Perform Transaction") |
| 143 | print("3. Check Balance") |
| 144 | print("4. Transaction History") |
| 145 | print("5. Exit") |
| 146 | |
| 147 | choice = input("Enter your choice: ") |
| 148 | |
| 149 | if choice == "1": |
| 150 | account_holder = input("Enter your name: ") |
| 151 | initial_balance = float(input("Enter initial balance: ")) |
| 152 | account = bank.create_account(account_holder, initial_balance) |
| 153 | print( |
| 154 | f"Account created successfully. Account Number: {account.account_number}" |
| 155 | ) |
| 156 | |
| 157 | elif choice == "2": |
| 158 | account_number = input("Enter account number: ") |
| 159 | transaction_type = input( |
| 160 | "Enter transaction type (deposit/withdraw): " |
| 161 | ).lower() |
| 162 | amount = float(input("Enter transaction amount: ")) |
| 163 | result = bank.perform_transaction(account_number, transaction_type, amount) |
| 164 | print(result) |
| 165 | |
| 166 | elif choice == "3": |
| 167 | account_number = input("Enter account number: ") |
| 168 | account = bank.get_account(account_number) |
| 169 | if account: |
| 170 | print(f"Account Balance: ${account.get_balance()}") |
| 171 | else: |
| 172 | print("Account not found.") |
| 173 | |
| 174 | elif choice == "4": |
| 175 | account_number = input("Enter account number: ") |
| 176 | transactions = bank.get_transaction_history(account_number) |
| 177 | if transactions: |
| 178 | print("Transaction History:") |
| 179 | for trans_type, amount in transactions: |
| 180 | print(f"{trans_type.capitalize()}: ${amount}") |
| 181 | else: |
| 182 | print("Account not found or no transaction history.") |
| 183 | |
| 184 | elif choice == "5": |
| 185 | print("Exiting the Python Banking System. Goodbye!") |
| 186 | break |
| 187 | |
| 188 | else: |
| 189 | print("Invalid choice. Please try again.") |
| 190 |
no test coverage detected