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

MCC_PS_cs

Uploaded by

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

MCC_PS_cs

Uploaded by

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

MCC PUBLIC SCHOOL

CHETPET, CHENNAI – 600031

COMPUTER SCIENCE
INVESTIGATORY PROJECT
2023 - 2024

ATM MANAGEMENT

Submitted by
E.Edmund jonathan

1
S.NO TABLE OF CONTENTS PAGE
NO
1 CERTIFICATE 3

2 ACKNOWLEDGMENT 4

3 AIM 5

4 INTRODUCTION 5

5 HARDWARE REQUIREMENTS 8

6 SOFTWARE REQUIREMENTS 8

7 CONCEPT’S USED 9

8 FLOW CHART

9 PROGRAM CODE 22

10 OUTPUT 28

11 CONCLUSION 28

12 BIBLIOGRAPHY

2
BONAFIDE CERTIFICATE
This is to certify that E.Edmund Jonathan of XII-A
from MCC PUBLIC SCHOOL, has successfully
completed the Computer Science Investigatory Project
on the topic ATM Management. Under the guidance
of Ms.Mohanapriya during the academic year 2023-
2024 in partial fulfilment of Computer Science practical
examination conducted by AISSCE, Delhi.

Dated: Signature of the teacher


(P.G.T in Computer Science)

School seal:

Submitted for All India Senior School Certificate


Practical Examination held___________ at Chennai.

Dated: Signature of External Examiner


(External Number)
3
ACKNOWLEDGMENT
My sincere compliments and gratitude to our
Computer Science teacher Ms. Mohanapriya for her
valuable suggestions, guidance, and encouragement in
completing the project.

I would also like to express my appreciation to our


Lab Assistant Mr. Dinesh for his help and support. A
special thanks goes to my parents and family members,
who supported me and encouraged me to complete this
project on time.

My special acknowledgement and gratitude to our


Principal ma'am Dr. Ms. Jolly S Mathew, for her
coordination in providing every support network to
ensure the success of this project.

4
AIM:
To generate an ATM- Management system in Python,
using the inter-connectivity with MySql program in
IDLE or Visual Code.

INTRODUCTION:
This Python script is an implementation of a simple
ATM (Automated Teller Machine) management system
using MySQL as the database to store account
information. The script provides basic ATM
functionalities, such as creating accounts, logging in,
checking account balances, making deposits and
withdrawals, changing account details, and listing all
accounts stored in the database.

Here's an overview of the key functions and features in


this ATM management system:

1. Database Interaction:
- It establishes a connection to a MySQL database on
a localhost server and creates a database called "atm" if
it doesn't already exist.
5
- It defines a table called "accounts" to store account-
related information, including account number, name,
password, balance, quick withdraw limit, account lock
status, and login attempts.

2. Account Creation:
- Users can create new accounts, and each account is
assigned a unique account number.
- Users provide their name, a strong password, initial
balance, and quick withdrawal limit when creating an
account.
- Account data is stored in the "accounts" table in the
database.

3. Account Login:
- Users can log in using their account number and
password.
- The script checks the provided credentials against
the database and grants access if they match.

4. Account Management Menu:


- Once logged in, users are presented with an account
management menu.
- The menu allows users to:
6
- Check their account balance.
- Make deposits into their account.
- Perform regular or quick withdrawals based on
their account balance and quick withdrawal limit.
- Change their account details, including their name
and password.
- Logout from their account.

5. Listing Accounts:
- Users have the option to view a list of all accounts
stored in the database.

6. Database Interaction and Updates:


- The script interacts with the database to update
account balances, store new accounts, and modify
account details.

7. Main Program Loop:


- The main program loop allows users to navigate
through various options until they choose to exit the
ATM system.

7
8. Exit Option:
- Users can exit the ATM system when they are done
with their transactions.

Please note that this is a simplified implementation for


educational (more like a prototype) purposes and does
not cover all security measures or error handling that
would be necessary in a real-world ATM system. In a
production system, additional security and error-
handling mechanisms should be implemented to ensure
the safety and reliability of the system.

HARDWARE REQUIERMENTS:
Processor: 12th Gen Intel(R) Core(TM) i7-12700 2.10
GHz

RAM: 16.0 GB

System Type: 64-bit operating system, x64-based


processor

Operating System: Windows 10 Pro

8
SOFTWARE REQUIREMENTS:
1. Python 3.11.4
2. MySql 8.0
3. MySql.connector

CONCEPT’S USED
Modules:
 Random: Use to generate account number
 MySQL. Connector: Use to connect python and
MySQL
Python:
 While loop
 Functions
My Sql:
 Basic MySQL queries like:
Select
Insert, Update

9
PROGRAM CODE
import random
import mysql.connector

# CONNECT TO MYSQL DATABASE


def connect_to_database():
connection = mysql.connector.connect(
host="localhost",
user="root",
password="root")
return connection

# CREAT THE ATM DATABASE IF IT DOSEN'T


EXIST
def create_database(cursor):
cursor.execute("CREATE DATABASE IF NOT
EXISTS atm")

10
# CREATE THE 'ACCOUNTS' TABLE IF IT
DOSEN'T EXIST
def create_table(cursor):
cursor.execute("""CREATE TABLE IF NOT
EXISTS accounts (
account_number INT PRIMARY KEY,
name VARCHAR(20),
password VARCHAR(20),
balance INT,
quick_withdraw INT,
is_locked BOOLEAN,
login_attempts INT
)""")

# CHECK IF THE 'ACCOUNTS' TABLE EXIST


IN THE DATABASE
def table_exists(cursor):
cursor.execute("SHOW TABLES LIKE 'accounts'")
return cursor.fetchone() is not None

# GENERATE A RANDOM ACCOUNT NUMBER


11
def generate_account_number():
return random.randint(1000000, 9999999)

# CREATE A NEW ACCOUNT


def create_account(connection, cursor):
while True:
account_number = generate_account_number()

cursor.execute("SELECT * FROM accounts


WHERE account_number = %s", (account_number,))
account = cursor.fetchone()

if not account:
break

name = input("Enter your name: ")


password = input("Enter a password(Password
should be very strong): ")
balance = int(input("Enter the initial balance: "))
quick_withdraw = int(input("Enter the quick
withdraw limit: "))
is_locked = False
12
login_attempts = 0

cursor.execute("""INSERT INTO accounts


(account_number, name, password, balance,
quick_withdraw, is_locked, login_attempts)
VALUES (%s, %s, %s, %s, %s, %s, %s)""",
(account_number, name, password, balance,
quick_withdraw, is_locked, login_attempts))
connection.commit()
print("Account created successfully. Account
number:", account_number)

# LOG IN TO AN EXISTING ACCOUNT


def login(connection, cursor):
account_number = int(input("Enter your account
number: "))
password = input("Enter your password: ")

cursor.execute("SELECT * FROM accounts


WHERE account_number = %s", (account_number,))
account = cursor.fetchone()

13
if account and account[2] == password:
print("Login successful. Welcome,", account[1])
account = list(account) # Convert the account
tuple to a list
logged_in = True
while logged_in:
logged_in = account_menu(connection, cursor,
account)
else:
print("Invalid account number or password.")

# DISPLAY THE ACCOUNT MENU


def account_menu(connection, cursor, account):
print("___________________________")
print(" --- Account Menu --- ")
print("1. Show balance ")
print("2. Deposit ")
print("3. Withdraw ")
print("4. Change account details ")
print("5. Logout ")
print("___________________________")

14
choice = input("Enter your choice: ")

if choice == "1":
show_balance(account)
elif choice == "2":
deposit(connection, cursor, account)
elif choice == "3":
withdraw(connection, cursor, account)
elif choice == "4":
change_account_details(connection, cursor,
account)
elif choice == "5":
print("Logged out successfully.")
return False
else:
print("Invalid choice. Please try again.")

return True

# SHOW ACCOUNT BALANCE

15
def show_balance(account):
print("--- Account Balance ---")
print("Balance:", account[3])

# Deposit funds into the account


def deposit(connection, cursor, account):
amount = int(input("Enter the amount to deposit: "))
new_balance = account[3] + amount

cursor.execute("UPDATE accounts SET balance =


%s WHERE account_number = %s",
(new_balance, account[0]))
connection.commit()
print("Deposit successful. New balance:",
new_balance)
account[3] = new_balance # Update the account
balance in the account list

# Withdraw funds from the account


def withdraw(connection, cursor, account):
print("_______________________")
print(" --- Withdraw Menu --- ")
16
print("1. Regular Withdraw " )
print("2. Quick Withdraw " )
print("_______________________")
choice = input("Enter your choice: ")

if choice == "1":
regular_withdraw(connection, cursor, account)
elif choice == "2":
quick_withdraw(connection, cursor, account)
else:
print("Invalid choice. Please try again.")

# REGULAR WITHDRAW
def regular_withdraw(connection, cursor, account):
amount = int(input("Enter the amount to withdraw:
"))

if amount <= account[3]:


new_balance = account[3] - amount
cursor.execute("UPDATE accounts SET balance =
%s WHERE account_number = %s",
(new_balance, account[0]))
17
connection.commit()
print("Regular withdraw successful. New
balance:", new_balance)
account[3] = new_balance # Update the account
balance in the account list
else:
print("Insufficient balance.")

# QUICK WITHDRAW
def quick_withdraw(connection, cursor, account):
quick_limit = account[4]

if quick_limit <= account[3]:


new_balance = account[3] - quick_limit
cursor.execute("UPDATE accounts SET balance =
%s WHERE account_number = %s",
(new_balance, account[0]))
connection.commit()
print("Quick withdraw of", quick_limit,
"successful. New balance:", new_balance)
account[3] = new_balance # Update the account
balance in the account list

18
else:
print("Insufficient balance for quick withdraw.")

# CHANGE ACCOUNT DETAILS


def change_account_details(connection, cursor,
account):
print("--- Change Account Details ---")
new_name = input("Enter a new name (leave blank
to keep current name): ")
new_password = input("Enter a new password (leave
blank to keep current password): ")

if new_name or new_password:
update_values = {}
if new_name:
update_values["name"] = new_name
if new_password:
update_values["password"] = new_password

update_query = "UPDATE accounts SET "


update_query += ", ".join("{} = %s".format(key)
for key in update_values.keys())

19
update_query += " WHERE account_number =
%s"

cursor.execute(update_query,
tuple(update_values.values()) + (account[0],))
connection.commit()
print("Account details updated.")
else:
print("No changes made to account details.")

# SHOW ALL ACCOUNTS IN THE DATABASE


def show_accounts(cursor):
cursor.execute("SELECT * FROM accounts")
accounts = cursor.fetchall()

if not accounts:
print("No accounts found.")
else:
print("--- Accounts ---")
for account in accounts:
print("Account Number:", account[0])
print("Name:", account[1])
20
print("---")

# Main program
def main():
connection = connect_to_database()
if connection is None:
return

cursor = connection.cursor()
create_database(cursor)
connection.database = "atm"
create_table(cursor)

while True:
print("________________________")
print(" --- ATM Management --- ")
print("1. Create account ")
print("2. Login ")
print("3. Show accounts ")
print("4. Exit ")
print("________________________")

21
choice = input("Enter your choice: ")

if choice == "1":
create_account(connection, cursor)
elif choice == "2":
login(connection, cursor)
elif choice == "3":
show_accounts(cursor)
elif choice == "4":
print("Exiting...")
print("THANK YOU")
break
else:
print("Invalid choice. Please try again.")

cursor.close()
connection.close()

22
# START THE PROGRAM
if __name__ == "__main__":
main()

23
OUTPUT:
PYTHON:

SQL:

PYTHON:

24
SQL:

PYTHON: 3

SQL: 3

25
PYTHON: 10

SQL: 10

PYTHON: 4

SQL: 4

26
PYTHON:

SQL:

PYTHON:

27
SQL:

PYTHON:

SQL:

28
PYTHON:

SQL:

PYTHON:

29
SQL:

CONCLUSION

BIBLIOGRAPHY
Source:
NCERT CS 12 text book
Trust me bro

30
31

You might also like