You are on page 1of 23

ST.

JOSEPH’’’`S SCHOOL

-INFORMATICS PRACTICE–S-
PROJECT
TOPIC : ATM MANAGEMENT SYSTEM

NAME : AMIT KUMAR


ROLL NUMBER :
SUBJECT CODE: 065
CLASS : XII HUMANITIES
SESSON : 2023-2024
ST. JOSEPH SCHOOL
Azara,Guwahati,781014

CERTIFICATE

This is to certify that Amit Kumar, a student of class XII


(Humanities) of St. Joseph School has successfully completed his
Political Science File on the topic “India's Current Realtion With
Russia And China”, under guidance and supervision. He has taken
proper care and utmost sincerity in the completion of this project.
All the work has been done by the candidate himself.

I certify that this project is up to my expectations and as per the


guidelines issued by Central Board Of Secondary
Education(CBSE).

………………………. .…………………..
Teacher In-Charge Principal

………………………..
External Examiner School Stamp
ST. JOSEPH SCHOOL
Azara,Guwahati,781014

ACKNOWLEDGEMENT

I would like to express my sincere gratitude to my Political Science,


teacher PRIYA DAS, of St. Joseph School, for her vital support,
guidance, and encouragement throughout this project. Without her
assistance, this project would not have been possible.

I also want to extend my heartfelt thanks to my teammates for their


undivided support and interest. They have inspired and encouraged
me to pursue my own path, without which I would have been
unable to complete this project.

Additionally, I would like to express my deep appreciation to our


school principal, Mr. Swaraj Sebastian, for their unwavering
support and belief in our abilities. Their guidance and
encouragement have created an environment that fosters
innovation and academic excellence.

Overall, I am immensely grateful to Priya Das, our Political Science


teacher, and our school principal for their invaluable contributions.
Their support and guidance have been instrumental in making this
project a fulfilling and successful experience.
INTRODUCTION
SQL TABLE STRUCTURE
SOURCE CODE
OUTPUT
TECH STACK
REQUIREMENT
REFERENCE
INTRODUCTON

The ATM Management System, built with Python and


MySQL, offers a range of features to streamline banking
transactions and enhance user experience. The system
includes secure user authentication to ensure account
privacy and prevent unauthorized access. Users can
conveniently withdraw cash from their accounts, check
their account balance, and transfer funds between
accounts. The system also allows users to update their
account information, such as contact details or address,
ensuring accurate and up-to-date records. With a user-
friendly command-line interface, the ATM Management
System provides a seamless and efficient banking
experience, empowering users to perform their transactions
swiftly and securely.
SQL TABLE STRUCTURE
1. Account
This table is used to store information about bank accounts:

2. Transaction
This table is used to record transaction details:

SOURCE CODE
import mysql.connector
import pandas as pd
import matplotlib.pyplot as plt
import random

# Connect to the MySQL database

db = mysql.connector.connect(
host="sql6.freesqldatabase.com",
user="sql6630736",
password="4sCuF1UzXH",
database="sql6630736"
)

# Create a cursor object to execute SQL queries


cursor = db.cursor()
# Create a table to store account information if it doesn't exist
cursor.execute("CREATE TABLE IF NOT EXISTS accounts (account_number INT
PRIMARY KEY, name VARCHAR(255), address VARCHAR(255), age INT, balance FLOAT,
pin INT)")

# Create a table to store transaction information if it doesn't exist


cursor.execute("CREATE TABLE IF NOT EXISTS transactions (transaction_id INT
AUTO_INCREMENT PRIMARY KEY, account_number INT, transaction_type
VARCHAR(255), amount FLOAT, timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP)")

# Function to generate a unique account number


def generate_account_number():
cursor.execute("SELECT MAX(account_number) FROM accounts")
result = cursor.fetchone()

if result[0]:
return result[0] + 1
else:
return 1

# Function to generate a random 4-digit PIN


def generate_pin():
return random.randint(1000, 9999)

# Function to create a bank account


def create_account():
name = input("Enter your name: ")
address = input("Enter your address: ")
age = int(input("Enter your age: "))

if age < 18:


print("Sorry, you must be at least 18 years old to open a bank
account.")
return

pin = generate_pin()
account_number = generate_account_number()

insert_query = "INSERT INTO accounts (account_number, name, address, age,


balance, pin) VALUES (%s, %s, %s, %s, %s, %s)"
values = (account_number, name, address, age, 0.0, pin)

cursor.execute(insert_query, values)
db.commit()
print("Account created successfully. Your account number is:",
account_number)
print("Your PIN is:", pin)

# Function to delete a bank account


def delete_account(account_number):
delete_query = "DELETE FROM accounts WHERE account_number = %s"
cursor.execute(delete_query, (account_number,))
db.commit()

if cursor.rowcount == 1:
print("Account deleted successfully.")
else:
print("Account not found.")

# Function to withdraw money from an account


def withdraw(account_number, amount):
query = "SELECT balance, pin FROM accounts WHERE account_number = %s"
cursor.execute(query, (account_number,))
result = cursor.fetchone()

if result:
balance, pin = result
entered_pin = input("Enter your 4-digit PIN: ")

if int(entered_pin) != pin:
print("Incorrect PIN. Withdrawal failed.")
return

if balance >= amount:


new_balance = balance - amount
update_query = "UPDATE accounts SET balance = %s WHERE
account_number = %s"
cursor.execute(update_query, (new_balance, account_number))
db.commit()

# Record the transaction


record_transaction(account_number, "Withdrawal", amount)

print("Withdrawal successful.")
else:
print("Insufficient balance.")
else:
print("Account not found.")

# Function to deposit money into an account


def deposit(account_number, amount):
query = "SELECT balance FROM accounts WHERE account_number = %s"
cursor.execute(query, (account_number,))
result = cursor.fetchone()

if result:
balance = result[0]
new_balance = balance + amount
update_query = "UPDATE accounts SET balance = %s WHERE account_number
= %s"
cursor.execute(update_query, (new_balance, account_number))
db.commit()

# Record the transaction


record_transaction(account_number, "Deposit", amount)

print("Deposit successful.")
else:
print("Account not found.")

# Function to transfer money between two accounts


def transfer(from_account, to_account, amount):
query = "SELECT balance FROM accounts WHERE account_number = %s"
cursor.execute(query, (from_account,))
sender_balance = cursor.fetchone()

cursor.execute(query, (to_account,))
receiver_balance = cursor.fetchone()

if sender_balance and receiver_balance:


sender_balance = sender_balance[0]
receiver_balance = receiver_balance[0]

if sender_balance >= amount:


sender_new_balance = sender_balance - amount
receiver_new_balance = receiver_balance + amount

update_query = "UPDATE accounts SET balance = %s WHERE


account_number = %s"
cursor.execute(update_query, (sender_new_balance, from_account))
cursor.execute(update_query, (receiver_new_balance, to_account))
db.commit()

# Record the transactions for both accounts


record_transaction(from_account, "Transfer to " +
str(to_account), amount)
record_transaction(to_account, "Transfer from " +
str(from_account), amount)

print("Transfer successful.")
else:
print("Insufficient balance.")
else:
print("One or both accounts not found.")

# Function to check the balance of an account


def check_balance(account_number):
query = "SELECT balance FROM accounts WHERE account_number = %s"
cursor.execute(query, (account_number,))
result = cursor.fetchone()

if result:
print("Account Balance:", result[0])
else:
print("Account not found.")

# Function to display all accounts


def display_accounts():
query = "SELECT * FROM accounts"
cursor.execute(query)
rows = cursor.fetchall()

if rows:
print("Account Details:")
for row in rows:
print("Account Number:", row[0])
print("Name:", row[1])
print("Address:", row[2])
print("Age:", row[3])
print("Balance:", row[4])
print("------------------------")
else:
print("No accounts found.")

# Function to plot a graph showing the total number of accounts with balance
def plot_account_balance_graph():
query = "SELECT balance FROM accounts"
cursor.execute(query)
rows = cursor.fetchall()

if rows:
balances = [row[0] for row in rows]
df = pd.DataFrame({"Balance": balances})

df.plot.hist(bins=10, edgecolor='black')
plt.xlabel("Balance")
plt.ylabel("Number of Accounts")
plt.title("Account Balance Distribution")
plt.show()
else:
print("No accounts found.")

# Function to reset the PIN for an account


def reset_pin(account_number):
new_pin = generate_pin()
update_query = "UPDATE accounts SET pin = %s WHERE account_number = %s"
cursor.execute(update_query, (new_pin, account_number))
db.commit()
print("PIN reset successful.")
print("Your new PIN is:", new_pin)

# Function to record a transaction


def record_transaction(account_number, transaction_type, amount):
insert_query = "INSERT INTO transactions (account_number,
transaction_type, amount) VALUES (%s, %s, %s)"
values = (account_number, transaction_type, amount)
cursor.execute(insert_query, values)
db.commit()

# Function to view transactions for a given account


def view_transactions(account_number):
query = "SELECT transaction_id, transaction_type, amount, timestamp FROM
transactions WHERE account_number = %s ORDER BY timestamp DESC LIMIT 5"
cursor.execute(query, (account_number,))
rows = cursor.fetchall()

if rows:
print("Last 5 Transactions:")
for row in rows:
print("Transaction ID:", row[0])
print("Transaction Type:", row[1])
print("Amount:", row[2])
print("Timestamp:", row[3])
print("------------------------")
else:
print("No transactions found.")

# Main program loop


while True:
print("1. Create a bank account")
print("2. Delete a bank account")
print("3. Withdraw money")
print("4. Deposit money")
print("5. Transfer money")
print("6. Check balance")
print("7. Display all accounts")
print("8. Plot account balance graph")
print("9. Reset PIN")
print("10. View last 5 transactions")
print("11. Exit")

choice = input("Enter your choice (1-11): ")

if choice == "1":
create_account()
elif choice == "2":
account_number = int(input("Enter the account number to delete: "))
delete_account(account_number)
elif choice == "3":
account_number = int(input("Enter your account number: "))
amount = float(input("Enter the withdrawal amount: "))
withdraw(account_number, amount)
elif choice == "4":
account_number = int(input("Enter your account number: "))
amount = float(input("Enter the deposit amount: "))
deposit(account_number, amount)
elif choice == "5":
from_account = int(input("Enter your account number: "))
to_account = int(input("Enter the recipient's account number: "))
amount = float(input("Enter the transfer amount: "))
transfer(from_account, to_account, amount)
elif choice == "6":
account_number = int(input("Enter your account number: "))
check_balance(account_number)
elif choice == "7":
display_accounts()
elif choice == "8":
plot_account_balance_graph()
elif choice == "9":
account_number = int(input("Enter your account number: "))
reset_pin(account_number)
elif choice == "10":
account_number = int(input("Enter your account number: "))
view_transactions(account_number)
elif choice == "11":
break
else:
print("Invalid choice. Please try again.")

# Close the database connection


db.close()

OUTPUT
1. MAIN UI:

The main menu after running the code


2. CREATING A BANK ACCOUNT:

Creating a new bank account for using ATM services

3. DELETING BANK ACCOUNT:

Deleting Account Using ATM services

4. WITHDRAW MONEY:

Withdrawing money from bank account


5. DEPOSIT:

Adding money in account using ATM service

6. TRANSFER:

Transferring money into another account


7. CHECK BALANCE:

Check Current Account Balance Using ATM services

8. DISPLAY ALL ACCOUNTS:

This is for admin to check all accounts in database


9. ACCOUNT BALANCE GRAPH:

This will help admin to get the accounts balance graph:


10. RESET PIN:

This allow user to reset their pin using ATM

11. VIEW LAST 5 TRANSACTIONS:

This allow users to get their last 5 transactions using ATM


12. EXIT:

This will close the program


TECH STACK
REQUIREMENT

 Hardware

- Pentium 3/4/Core 2 Duo/Dual core/Pentium/i3/i5/i7, 256


MB RAM
- 2 MB free space on Hard Disk Colour
- Monitor/LCD

 Operating System & Compiler

- Windows 7 or higher
- Python
- Visual Studio Code or Any IDE
BIBLIOGRAPHY

- Class Notes
- Google
- Bard
- Wikipedia
- Youtube
- Republic Bharat Tv

Thanking all the resources provider!

You might also like