Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
8 views

Computer Project Report

Uploaded by

ryash2327
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Computer Project Report

Uploaded by

ryash2327
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 33

BANKING

SYSTEM

NAME:

CLASS AND SECTION: 12 A

REGISTRATION NUMBER:
INDEX
Sr No. Topic Page No.
1 Acknowledgement 3
2 Aim 4
3 Overview 5
4 Synopsis 6
5 Tables in Database 7
6 Requirements 8
7 Source code 9
8 Output 26
9 Conclusion 32
10 Bibliography 33
ACKNOWLEDGMENT
I am deeply grateful to everyone who supported and guided me during the development of this
project, helping make it a fruitful and rewarding journey.

First and foremost, I would like to express my sincere appreciation to my teacher, Ms. Sumitha
Suresh, for her unwavering guidance, encouragement, and mentorship throughout the project.
Her constructive feedback, insightful suggestions, and continuous support were instrumental in
overcoming challenges and achieving milestones during the process.

I extend my heartfelt gratitude to Mr. Suresh Balakrishnan, the Principal of Private International
English School, and the esteemed School Management, for providing the essential facilities and
creating an enabling environment that allowed me to focus on and complete this project
successfully. Their trust and encouragement were pivotal in giving me the confidence to move
forward.

A special acknowledgment goes to my family for their boundless love, unwavering support, and
motivation. Their faith in my abilities inspired me to push my boundaries and strive for
excellence in every aspect of this project. They have been my constant source of strength and
encouragement.

I would also like to thank my peers and friends who stood by me, offering cooperation,
companionship, and collaboration throughout the journey. Their teamwork, dedication, and
shared vision greatly contributed to the success of this project, making the experience both
enjoyable and enriching.
AIM
The aim of this project is to develop a functional Banking System that simulates key banking
operations in a secure and user-friendly environment.

The system will enable users to perform fundamental tasks such as account creation, secure login
authentication, fund transfers, simple interest calculations, loan management, and access to
account statements. By integrating these features, the project aims to provide hands-on
experience of banking processes while demonstrating the practical application of programming
and computational concepts.

A banking system is an integral part of modern financial infrastructure, enabling individuals and
organizations to manage their finances securely and efficiently. It provides various services,
including account management, fund transfers, loan processing, and financial reporting, making
it essential for facilitating economic activities and promoting financial literacy. Modern banking
systems emphasize automation, security, and user convenience, leveraging technology to
streamline processes and enhance accessibility.

This project aims to replicate these core functionalities in a simplified yet functional manner to
provide a practical understanding of banking operations.
OVERVIEW

Python is a high-level, interpreted programming language renowned for its readability and
simplicity. Its clear syntax makes it an excellent choice for beginners, while its versatility allows
experienced developers to use it across various domains. Python supports multiple programming
paradigms, including procedural, object-oriented, and functional programming, which adds to its
flexibility. The language boasts a rich ecosystem filled with libraries and frameworks such as
NumPy, pandas, Django, and Flask, which facilitate everything from data analysis to web
development. Moreover, Python benefits from a large and active community that contributes
extensive resources, documentation, and third-party modules, making it easier for users to find
help and enhance their projects.

On the other hand, SQL (Structured Query Language) is a standardized language specifically
designed for managing and manipulating relational databases. It provides a powerful way to
interact with data stored in tables, allowing users to perform a range of operations such as
querying data, updating records, and creating or modifying database structures. SQL is a
declarative language, meaning it focuses on what data to retrieve or manipulate rather than
detailing the steps to do so, making it user-friendly and efficient. Key commands in SQL include
SELECT, INSERT, UPDATE, DELETE, and CREATE TABLE, among others. These
commands enable users to easily manage and maintain data integrity within their databases.

In summary, both Python and SQL are essential tools in the programming and data management
landscape. Python’s versatility lends itself to a wide array of applications, from web
development to data science, while SQL remains fundamental for effective database
management. Together, they complement each other exceptionally well, especially in data-driven
projects where Python can be employed to analyze and visualize data sourced from SQL
databases. This combination empowers developers to create robust, data-centric applications and
solutions.
SYNOPSIS

This project integrates Python and SQL to create a dynamic and efficient data management and
analysis system. The project involves designing a system where Python scripts interact with an
SQL database to perform various operations such as data insertion, querying, updating, and
deletion.

Key functionalities include:

User Authentication:
 Username and Password for secure login.
Multiple Account Types and Account Creation:
 Savings Account: Includes Simple Interest Calculation.
 Checking Account: Allows basic deposit and withdrawal functions without interest.
Simple Interest Calculation:
 View interest accumulated over time.
 Applies to Savings accounts only.
 Withdrawal limit for the number of times per month.
Basic Fund Transfer:
 Transfer funds within the same user account (self-transfer option).
 Transfer funds between different user accounts.
Loan Management:
 Loan Applications: Users can apply for loans with different conditions and interest
rates.
 Loan Repayment: Manual repayment option for users, with tracking by the system.
Account Statement:
 Users can view a complete transaction history of processed transactions.
Tables in Database
REQUIREMENTS

Software Requirements:

1)Windows 10 or higher

2)MySQL

3)Python

4)MySQL connector

Hardware Requirements:

1)Laptop/Computer

2)Keyboard

3)Processors such as AMD Anthlon X2 64 2.4 GHz

4)Minimum 1GB RAM

5)Hard Disk: 10GB to 20GB


SOURCE CODE

import mysql.connector

from mysql.connector import Error

import datetime

def create_connection():

try:

connection = mysql.connector.connect(

host="localhost",

# database="banking_system",

database="test_banking",

user="root",

password="mysql",

port=3307

if connection.is_connected():

print("Connection to MySQL DB successful")

return connection

except Error as e:

print(f"Error: '{e}'")

return None
def register_user(connection, username, password):

cursor = connection.cursor()

try:

cursor.execute(

"INSERT INTO Users (username, password) VALUES (%s,


%s)",

(username, password),

connection.commit()

print("User registered successfully!")

except Error as e:

print(f"Error: '{e}'")

def login_user(connection, username, password):

cursor = connection.cursor()

cursor.execute(

"SELECT * FROM Users WHERE username=%s AND password=%s",


(username, password)

user = cursor.fetchone()

if user:

print("Login successful!")

return user

else:

print("Login failed!")
return None

def create_account(connection, user_id, account_type):

cursor = connection.cursor()

interest_rate = 3.5 if account_type == "savings" else 0.0

cursor.execute(

"INSERT INTO Accounts (user_id, account_type,


interest_rate, last_interest_date) VALUES (%s, %s, %s,
CURDATE())",

(user_id, account_type, interest_rate),

connection.commit()

print(f"{account_type.capitalize()} account created


successfully!")

def deposit(connection, user_id, account_id, amount):

cursor = connection.cursor()

cursor.execute(

"UPDATE Accounts SET balance = balance + %s WHERE id =


%s", (amount, account_id)

cursor.execute(

"INSERT INTO Transactions (user_id, account_id,


transaction_type, amount, transaction_date) VALUES (%s, %s,
'deposit', %s, CURDATE())",

(user_id, account_id, amount),


)

connection.commit()

print("Deposit successful!")

def withdraw(connection, user_id, account_id, amount):

cursor = connection.cursor()

cursor.execute("SELECT balance FROM Accounts WHERE id = %s


AND user_id = %s", (account_id, user_id))

balance = cursor.fetchone()

if balance:

balance = balance[0]

else:

print("Unauthorised user for account")

return

if balance >= amount:

cursor.execute(

"UPDATE Accounts SET balance = balance - %s WHERE id


= %s",

(amount, account_id),

# today = datetime.date.today().isoformat()

# print(today)

cursor.execute(
"INSERT INTO Transactions (user_id, account_id,
transaction_type, amount, transaction_date) VALUES (%s, %s,
'withdrawal', %s, now())",

(user_id, account_id, amount),

connection.commit()

print("Withdrawal successful!")

return True

else:

print("Insufficient balance!")

return False

def calculate_interest(connection, account_id):

cursor = connection.cursor()

cursor.execute(

"SELECT balance, interest_rate, last_interest_date,


account_type FROM Accounts WHERE id = %s",

(account_id,),

balance, interest_rate, last_interest_date, account_type =


cursor.fetchone()

if account_type != "savings":

print("Account is not a savings account")

return

today = datetime.date.today()

days_diff = (today - last_interest_date).days


if days_diff > 0:

interest = (balance * interest_rate * days_diff) / (365 *


100)

cursor.execute(

"UPDATE Accounts SET balance = balance + %s,


last_interest_date = %s WHERE id = %s",

(interest, today, account_id),

connection.commit()

print(f"Interest calculated: {interest:.2f}")

else:

print("Last interest was already added today")

def transfer_funds(connection, user_id, from_account_id,


to_account_id, amount):

if withdraw(connection, user_id, from_account_id, amount):

deposit(connection, user_id, to_account_id, amount)

print("Funds transferred successfully!")

def apply_for_loan(connection, user_id, loan_amount,


interest_rate, loan_period):

cursor = connection.cursor()

cursor.execute(

"INSERT INTO Loans (user_id, loan_amount, interest_rate,


loan_period) VALUES (%s, %s, %s, %s)",

(user_id, loan_amount + (loan_amount * interest_rate *


loan_period) / 1200, interest_rate, loan_period),
)

connection.commit()

print("Loan application successful!")

def repay_loan(connection, loan_id, account_id, amount, user_id):

cursor = connection.cursor()

query = """

SELECT loan_amount FROM Loans WHERE id = %s

"""

cursor.execute(query, (loan_id, ))

loan_amount = cursor.fetchone()[0]

is_active = "True"

if amount - float(loan_amount) >= 0:

is_active = "False"

if withdraw(connection, user_id, account_id, amount):

cursor.execute(

"UPDATE Loans SET loan_amount = loan_amount - %s ,


active = %s WHERE id = %s",

(amount, is_active, loan_id),

connection.commit()

print("Loan repayment successful!")


else:

print("Repayment Failed")

def view_statement(connection, account_id):

cursor = connection.cursor()

cursor.execute("SELECT * FROM Transactions WHERE account_id =


%s", (account_id,))

transactions = cursor.fetchall()

if not transactions:

print("No transactions found")

return

print(f'{"Account ID":<10} {"Transaction Type":<16}


{"Amount":<8} {"Transaction Date":<10}')

for transaction in transactions:

print(f'{transaction[2]:<10} {transaction[3]:<16}
{transaction[4]:<8} {str(transaction[5])[:-9]}')

def get_all_active_loans(connection, user_id):

cursor = connection.cursor()

query = """

SELECT * FROM Loans

WHERE user_id = %s AND active = "True"

"""

cursor.execute(query, (user_id, ))

active_loans = cursor.fetchall()
if active_loans:

print("\nYour Loans:")

for loan in active_loans:

loan_id, _, _, loan_amount, interest_rate,


loan_period = (

loan

print(f"Loan ID: {loan_id}")

print(f"Loan Amount: ${loan_amount}")

print(f"Interest Rate: {interest_rate}% per


annum")

print(f"loan_period: {loan_period}")

print("-" * 30)

else:

print("No Loans found.")

return active_loans

def get_all_accounts(connection, user_id):

cursor = connection.cursor()

query = """

SELECT id, account_type, balance, interest_rate,


last_interest_date

FROM Accounts
WHERE user_id = %s

"""

cursor.execute(query, (user_id,))

accounts = cursor.fetchall()

if accounts:

print("\nYour Accounts:")

for account in accounts:

account_id, account_type, balance, interest_rate,


last_interest_date = (

account

print(f"Account ID: {account_id}")

print(f"Account Type: {account_type.capitalize()}")

print(f"Balance: ${balance:.2f}")

print(f"Interest Rate: {interest_rate}% per annum")

print(f"Last Interest Date: {last_interest_date}")

print("-" * 30)

else:

print("No accounts found.")

return accounts

def setup_database(connection):
query = """

CREATE TABLE Users (

id INT AUTO_INCREMENT PRIMARY KEY,

username VARCHAR(50) NOT NULL UNIQUE,

password VARCHAR(255) NOT NULL

);

CREATE TABLE Accounts (

id INT AUTO_INCREMENT PRIMARY KEY,

user_id INT,

account_type ENUM('savings', 'checkings'),

balance DECIMAL(15, 2) DEFAULT 0.00,

interest_rate DECIMAL(5, 2) DEFAULT 0.00,

last_interest_date DATE,

FOREIGN KEY (user_id) REFERENCES Users(id)

);

CREATE TABLE Transactions (

id INT AUTO_INCREMENT PRIMARY KEY,

user_id INT NOT NULL,

account_id INT NOT NULL,

transaction_type VARCHAR(50),

amount DECIMAL(10, 2),


transaction_date DATETIME,

FOREIGN KEY (user_id) REFERENCES Users(id),

FOREIGN KEY (account_id) REFERENCES Accounts(id)

);

CREATE TABLE Loans (

id INT AUTO_INCREMENT PRIMARY KEY,

user_id INT,

active varchar(5) DEFAULT 'True',

loan_amount DECIMAL(15, 2),

interest_rate DECIMAL(5, 2),

loan_period INT, -- Loan period in months

FOREIGN KEY (user_id) REFERENCES Users(id)

);

"""

cursor = connection.cursor()

cursor.execute("show tables")

existing_tables = cursor.fetchall()

if not existing_tables:

cursor.execute(query)

def main():
connection = create_connection()

if not connection:

return

setup_database(connection)

while True:

print("\nWelcome to the Banking System")

print("1. Register")

print("2. Login")

print("3. Exit")

choice = input("Choose an option: ")

if choice == "1":

username = input("Enter username: ")

password = input("Enter password: ")

register_user(connection, username, password)

elif choice == "2":

username = input("Enter username: ")

password = input("Enter password: ")

user = login_user(connection, username, password)

if user:

user_menu(connection, user)
elif choice == "3":

print("Exiting...")

break

else:

print("Invalid choice. Please try again.")

connection.close()

def user_menu(connection, user):

should_exit = False

while not should_exit:

try:

print("\nUser Menu")

print("1. Create Account")

print("2. Deposit")

print("3. Withdraw")

print("4. Transfer Funds")

print("5. Apply for Loan")

print("6. Repay Loan")

print("7. View Account Statement")

print("8. View All Accounts")

print("9. View All Loans")

print("10. Calculate Interest")


print("11. Logout")

choice = input("Choose an option: ")

if choice == "1":

account_type = input("Enter account type


(savings/checkings): ")

create_account(connection, user[0], account_type)

elif choice == "2":

account_id = int(input("Enter account ID: "))

amount = float(input("Enter amount to deposit:


"))

deposit(connection, user[0], account_id, amount)

elif choice == "3":

account_id = int(input("Enter account ID: "))

amount = float(input("Enter amount to withdraw:


"))

withdraw(connection, user[0], account_id, amount)

elif choice == "4":

from_account_id = int(input("Enter your account


ID: "))

to_account_id = int(input("Enter recipient


account ID: "))

amount = float(input("Enter amount to transfer:


"))

transfer_funds(connection, user[0],
from_account_id, to_account_id, amount)

elif choice == "5":


loan_amount = float(input("Enter loan amount: "))

interest_rate = float(input("Enter interest rate:


"))

loan_period = int(input("Enter loan period (in


months): "))

apply_for_loan(connection, user[0], loan_amount,


interest_rate, loan_period)

elif choice == "6":

loan_id = int(input("Enter loan ID: "))

repay_from_account_id = int(input("Enter account


to repay from: "))

amount = float(input("Enter amount to repay: "))

repay_loan(connection, loan_id,
repay_from_account_id, amount, user[0])

elif choice == "7":

account_id = int(input("Enter account ID: "))

view_statement(connection, account_id)

elif choice == "8":

get_all_accounts(connection, user[0])

elif choice == "9":

get_all_active_loans(connection, user[0])

elif choice == "10":

account_id = int(input("Enter account ID: "))

calculate_interest(connection, account_id)

elif choice == "11":

print("Logging out...")
should_exit = True

else:

print("Invalid choice. Please try again.")

except:

user_menu(connection, user)

if __name__ == "__main__":

main()

OUTPUT
1. Registering a new user account

Welcome to the Banking System


1. Register
2. Login
3. Exit
Choose an option: 1
Enter username: YashRaj
Enter password: 12345678
User registered successfully!

2. Login in into the banking system

Welcome to the Banking System


1. Register
2. Login
3. Exit
Choose an option: 2
Enter username: YashRaj
Enter password: 12345678
Login successful!

3. Create a new bank account


a. Savings

User Menu
1. Create Account
2. Deposit
3. Withdraw
4. Transfer Funds
5. Apply for Loan
6. Repay Loan
7. View Account Statement
8. View All Accounts
9. View All Loans
10. Calculate Interest
11. Logout
Choose an option: 1
Enter account type (savings/checkings): savings
Savings account created successfully!

b. Checkings

User Menu
1. Create Account
2. Deposit
3. Withdraw
4. Transfer Funds
5. Apply for Loan
6. Repay Loan
7. View Account Statement
8. View All Accounts
9. View All Loans
10. Calculate Interest
11. Logout
Choose an option: 1
Enter account type (savings/checkings): checkings
Checkings account created successfully!

4. View all the bank accounts you have

User Menu
1. Create Account
2. Deposit
3. Withdraw
4. Transfer Funds
5. Apply for Loan
6. Repay Loan
7. View Account Statement
8. View All Accounts
9. View All Loans
10. Calculate Interest
11. Logout
Choose an option: 8

Your Accounts:
Account ID: 7
Account Type: Savings
Balance: $0.00
Interest Rate: 3.50% per annum
Last Interest Date: 2024-11-16
------------------------------
Account ID: 8
Account Type: Checkings
Balance: $0.00
Interest Rate: 0.00% per annum
Last Interest Date: 2024-11-16
------------------------------

5. Deposit money in bank account:

User Menu
1. Create Account
2. Deposit
3. Withdraw
4. Transfer Funds
5. Apply for Loan
6. Repay Loan
7. View Account Statement
8. View All Accounts
9. View All Loans
10. Calculate Interest
11. Logout
Choose an option: 2
Enter account ID: 7
Enter amount to deposit: 10000
Deposit successful!

6. Withdraw money from bank account:

User Menu
1. Create Account
2. Deposit
3. Withdraw
4. Transfer Funds
5. Apply for Loan
6. Repay Loan
7. View Account Statement
8. View All Accounts
9. View All Loans
10. Calculate Interest
11. Logout
Choose an option: 3
Enter account ID: 7
Enter amount to withdraw: 1000
Withdrawal successful!

7. Transfer funds between accounts:

User Menu
1. Create Account
2. Deposit
3. Withdraw
4. Transfer Funds
5. Apply for Loan
6. Repay Loan
7. View Account Statement
8. View All Accounts
9. View All Loans
10. Calculate Interest
11. Logout
Choose an option: 4
Enter your account ID: 7
Enter recipient account ID: 8
Enter amount to transfer: 1000
Withdrawal successful!
Deposit successful!
Funds transferred successfully!

8. Apply for a loan:

User Menu
1. Create Account
2. Deposit
3. Withdraw
4. Transfer Funds
5. Apply for Loan
6. Repay Loan
7. View Account Statement
8. View All Accounts
9. View All Loans
10. Calculate Interest
11. Logout
Choose an option: 5
Enter loan amount: 100000
Enter interest rate: 2.5
Enter loan period (in months): 36
Loan application successful!

9. View all loans:

User Menu
1. Create Account
2. Deposit
3. Withdraw
4. Transfer Funds
5. Apply for Loan
6. Repay Loan
7. View Account Statement
8. View All Accounts
9. View All Loans
10. Calculate Interest
11. Logout
Choose an option: 9

Your Loans:
Loan ID: 5
Loan Amount: $107500.00
Interest Rate: 2.50% per annum
loan_period: 36
------------------------------

10. Repay loan:

User Menu
1. Create Account
2. Deposit
3. Withdraw
4. Transfer Funds
5. Apply for Loan
6. Repay Loan
7. View Account Statement
8. View All Accounts
9. View All Loans
10. Calculate Interest
11. Logout
Choose an option: 6
Enter loan ID: 5
Enter account to repay from: 7
Enter amount to repay: 500
Withdrawal successful!
Loan repayment successful!

11. View account statement for a bank account:

User Menu
1. Create Account
2. Deposit
3. Withdraw
4. Transfer Funds
5. Apply for Loan
6. Repay Loan
7. View Account Statement
8. View All Accounts
9. View All Loans
10. Calculate Interest
11. Logout
Choose an option: 7
Enter account ID: 7
Account ID Transaction Type Amount Transaction Date
7 deposit 10000.00 2024-11-16
7 withdrawal 1000.00 2024-11-16
7 withdrawal 1000.00 2024-11-16
7 withdrawal 500.00 2024-11-16
12. Calculate and get interest for a savings account:

User Menu
1. Create Account
2. Deposit
3. Withdraw
4. Transfer Funds
5. Apply for Loan
6. Repay Loan
7. View Account Statement
8. View All Accounts
9. View All Loans
10. Calculate Interest
11. Logout
Choose an option: 10
Enter account ID: 7
Interest calculated: 2.16

13. Logout and exit the banking system:

User Menu
1. Create Account
2. Deposit
3. Withdraw
4. Transfer Funds
5. Apply for Loan
6. Repay Loan
7. View Account Statement
8. View All Accounts
9. View All Loans
10. Calculate Interest
11. Logout
Choose an option: 11
Logging out...

Welcome to the Banking System


1. Register
2. Login
3. Exit
Choose an option: 3
Exiting...

CONCLUSION
The banking system project successfully integrates and implements all the necessary features for
efficient banking operations. It covers essential functionalities such as user account management,
transaction processing, and secure data handling, ensuring smooth interaction and reliability.

Key components like account creation, balance checking, and transaction recording are
effectively implemented, providing a seamless experience for users. The system ensures security
through user authentication, safeguarding both customer data and transaction integrity.

This project lays a strong foundation for future expansion, allowing additional features like loan
processing or investment management to be added with ease. Overall, the system meets the core
requirements of modern banking, delivering a secure, efficient, and user-friendly solution.

BIBLIOGRAPHY
 “Computer Science with Python.” Sumitha Arora, 1st Edition, Dhanpat Rai
Publications, 2021.
 “Computer Science 50: Introduction to Python.” Harvard University, CS50p.
 “MySQL Documentation.” MySQL. https://dev.mysql.com/doc/.
 “Python Official Documentation.” Python Software Foundation.
https://docs.python.org/.

You might also like