0% found this document useful (0 votes)
7 views

python_lab_report

The lab report details the development of a Banking Application using Python, focusing on various account classes such as Account, SavingAccount, CurrentAccount, and BusinessAccount. It outlines the implementation of core banking functionalities, user interactions, and error handling within the system. The report also describes the system's user-friendly interface for managing accounts, including options for opening accounts, depositing, withdrawing, and viewing account details.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

python_lab_report

The lab report details the development of a Banking Application using Python, focusing on various account classes such as Account, SavingAccount, CurrentAccount, and BusinessAccount. It outlines the implementation of core banking functionalities, user interactions, and error handling within the system. The report also describes the system's user-friendly interface for managing accounts, including options for opening accounts, depositing, withdrawing, and viewing account details.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

University of Information Technology

and Sciences (UITS)


Department of Information Technology

design pattern lab report


IT 324 : design pattern Lab

Lab Report

Submitted To: Submitted By:


Barsha Roy Name: Ankon Bose
Lecturer, Student ID: 2114955003
Department of IT, UITS Name: Shohanul Islam
Email : Student ID:2114955005
[email protected] Name: Arnob Podder
Student ID: 2114955004
Name: Sangita Alam Mim
Student
ID:0432220005191009
Lab Report sangita

December 1, 2024

Department of IT, UITS © All rights reserved.

2
Lab Report sangita

Contents
1 Problem Statement 2

2 Code for Module 2

3 Description of Implementation 6

4 Output 6

5 Module’s Working Procedure 8

1
Lab Report sangita

1 Problem Statement
Creating a Banking Application

2 Code for Module


This lab report contain Python codes.
Code for account class
1 class Account :
2 def __init__ ( self , account_number , user_name , balance ,
account_type ) :
3 self . account_number = account_number
4 self . user_name = user_name
5 self . balance = balance
6 self . account_type = account_type
7
8
9 def display ( self ) :
10 print ( " Account Details : " )
11 # print ( f " Account Number : { self . account_number }")
12 print ( f " User Name : { self . user_name } " )
13 print ( f " Balance : { self . balance } " )
14
15 def deposit ( self , amount ) :
16 self . balance = self . balance + amount
17
18 def get_balance ( self ) :
19 return self . balance
20
21 def withdraw ( self , amount ) :
22 if amount < self . balance :
23 self . balance -= amount
24 return amount
25 else :
26 print ( " Insufficient Balance " )

Code for saving account class


1 from account import Account
2
3
4 class SavingAccount ( Account ) :
5 def __init__ ( self , account_number , user_name , balance , account_type
, interest = 0.03) :
6 super () . __init__ ( account_number , user_name , balance ,
account_type )
7 self . interest = interest

2
Lab Report sangita

Code for current account class


1 from account import Account
2
3 class CurrentAccount ( Account ) :
4 def __init__ ( self , account_number , user_name , balance ,
account_type , withdraw_limit =50000) :
5 super () . __init__ ( account_number , user_name , balance ,
account_type )
6 self . withdraw_limit = withdraw_limit
7

8 def withdraw ( self , amount ) :


9 if amount <= self . balance and amount <= self . withdraw_limit
:
10 self . balance -= amount
11 return amount
12 else :
13 print ( " Exceeds withdraw limit or insufficient funds ! " )
14 return 0

Code for business account class


1 from account import Account
2
3 class BusinessAccount ( Account ) :
4 def __init__ ( self , account_number , user_name , balance ,
account_type , transaction_fee =50) :
5 super () . __init__ ( account_number , user_name , balance ,
account_type )
6 self . transaction_fee = transaction_fee
7
8 def withdraw ( self , amount ) :
9 total_amount = amount + self . transaction_fee
10 if total_amount <= self . balance :
11 self . balance -= total_amount
12 return amount
13 else :
14 print ( " Insufficient Balance ( including transaction fee )
!")
15 return 0

Code for main class


1 from saving_account import SavingAccount
2 from current_account import CurrentAccount
3 from business_account import BusinessAccount
4
5

6 import random
7
8 accounts = {}
9

3
Lab Report sangita

10 def g e n e r a t e _ a c c o u n t _ n u m b e r () :
11 return random . randint (10000 , 99999)
12
13 def main () :
14 print ( " \ nWelcome to Bank Management System ! " )
15
16 while True :
17 print ( " \ n1 . Open an Account " )
18 print ( " 2. Deposit Money " )
19 print ( " 3. Withdraw Money " )
20 print ( " 4. Display Account Details " )
21 print ( " 5. Exit " )
22
23 try :
24 choice = int ( input ( " Enter your choice : " ) )
25 except ValueError :
26 print ( " Invalid input ! Please enter a valid number . " )
27 continue
28
29 if choice == 1:
30 username = input ( " Enter your banking user name : " )
31 account_number = g e n e r a t e _ a c c o u n t _ n u m b e r ()
32 account_type = int ( input ( " Enter Account Type :\ n1 .
Savings Account \ n2 . Current Account \ n3 . Business Account \ n : - " ) )
33
34 if account_type == 1:
35 account = SavingAccount ( account_number , username ,
0 , " Savings " )
36 elif account_type == 2:
37 account = CurrentAccount ( account_number , username ,
0 , " Current " )
38 elif account_type == 3:
39 account = BusinessAccount ( account_number , username ,
0 , " Business " )
40 else :
41 print ( " Invalid Account Type ! Please try again . " )
42 continue
43

44 accounts [ account_number ] = account


45 print ( f " Account Created Successfully ! Your Account
Number is { account_number } " )
46
47 elif choice == 2:
48 acc_num = int ( input ( " Enter your account number : " ) )
49 if acc_num in accounts :
50 amount = float ( input ( " Enter amount to deposit : " ) )
51 accounts [ acc_num ]. deposit ( amount )
52 print ( " Deposit Successful ! " )
53 else :
54 print ( " Account not found ! " )
55

4
Lab Report sangita

56 elif choice == 3:
57 acc_num = int ( input ( " Enter your account number : " ) )
58 if acc_num in accounts :
59 amount = float ( input ( " Enter amount to withdraw : " ) )
60 accounts [ acc_num ]. withdraw ( amount )
61 else :
62 print ( " Account not found ! " )
63

64 elif choice == 4:
65 acc_num = int ( input ( " Enter your account number : " ) )
66 if acc_num in accounts :
67 accounts [ acc_num ]. display ()
68 else :
69 print ( " Account not found ! " )
70
71 elif choice == 5:
72 print ( " Thank you for using the Bank Management System .
Goodbye ! " )
73 break
74

75 else :
76 print ( " Invalid choice ! Please select a valid option . " )
77
78 if __name__ == " __main__ " :
79 main ()

5
Lab Report sangita

3 Description of Implementation
The Account class serves as the foundational blueprint for all account types in the
banking system. It encapsulates common attributes and methods that are shared
across different account types. The class focuses on core banking functionalities
such as depositing and withdrawing money. It ensures the encapsulation of common
operations, providing a base for specialized account types to extend and override as
necessary.
The saving account inherits from Account and introduces an additional attribute
specific to savings accounts interest. This class inherits the basic functionalities from
Account and adds the capability to calculate interest (to be implemented if needed
for advanced functionality). This class extends the Account class and introduces a
withdrawal limit to restrict the maximum amount that can be withdrawn at a time.
This class extends the Account class and introduces a withdrawal limit to restrict
the maximum amount that can be withdrawn at a time. This ensures tighter control
over withdrawals, a feature typical of current accounts.
BusinessAccount Class ( class further specializes the Account class by adding a
transaction fee for every withdrawal. It adds an additional layer of cost control by
charging a fee for withdrawals, mimicking real-world business account practices.
The main.py file acts as the entry point for the Banking Management System. It
uses the classes defined above to provide a user interface for interacting with the
system. The system stores all accounts in a dictionary (accounts), using account
numbers as keys. Error handling ensures invalid inputs do not crash the program.
Supports seamless extension with additional account types and features.

4 Output

Figure 1: fig 1

6
Lab Report sangita

Figure 2: fig 2

Figure 3: fig 3

Figure 4: fig 4

7
Lab Report sangita

5 Module’s Working Procedure


The Banking Management System is designed to make managing accounts simple
and user-friendly. Here’s an overview of how it works:
1. Starting the System- When you launch the system, a welcome message greets
you, followed by a menu of options. You can choose what you’d like to do, such as
opening an account, depositing money, withdrawing money, viewing your account
details, or exiting the system.
2. Opening an Account- To open an account, you’ll need to enter your name and
select the type of account:
i) Savings Account: Ideal for earning interest on your balance.
ii) Current Account: Great for everyday banking with a withdrawal limit for added
security.
iii) Business Account: Perfect for businesses, with a small fee for every transaction.
The system creates a unique account number just for you, and your account is ready
to use!
3. Depositing Money- To add money to your account, simply enter your account
number and the amount you’d like to deposit.
The system confirms the deposit and updates your balance instantly.
4. Withdrawing Money- Need to withdraw cash? Just enter your account number
and the amount. Depending on your account type:
Savings Account: You can withdraw as long as there’s enough balance.
Current Account: The system ensures you stay within the allowed withdrawal limit.
Business Account: A small transaction fee is added to your withdrawal amount.
If there’s an issue, like insufficient funds or exceeding the limit, the system lets you
know right away.
5. Viewing Account Details- Curious about your account? Just enter your account
number to see details like:
Your name.
Your current balance.
Special features like your interest rate, withdrawal limit, or transaction fee. It’s a
quick and easy way to stay on top of your finances.

8
Lab Report sangita

6. Exiting the System- When you’re done, select the exit option. The system thanks
you for using it and safely shuts down.
Example of Using the System:
Opening an Account: You open a Business Account with the name Jane Smith. The
system assigns you an account number, say 54321.
Depositing Money: You deposit 5, 000intoyournewaccount.T hesystemconf irmsthedeposit, andyourb
Withdrawing Money: You withdraw 1, 000.T hesystemdeducts1,050 (including a
50transactionf ee), leavingyouwith3,950.
Checking Account Details: You check your account details and see your name,
balance, and the transaction fee information.
Exiting: You select the exit option, and the system thanks you for using the service.

You might also like