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

Sample Project-CS

This document outlines a project report for an ATM simulation created using Python, detailing its purpose, hardware and software requirements, and functionalities such as cash withdrawal, deposit, and fund transfer. It includes sections for acknowledgments, source code, and sample outputs, demonstrating the project's implementation and user interaction. The project serves as a practical application for students in the Computer Science academic curriculum for the year 2020-21.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Sample Project-CS

This document outlines a project report for an ATM simulation created using Python, detailing its purpose, hardware and software requirements, and functionalities such as cash withdrawal, deposit, and fund transfer. It includes sections for acknowledgments, source code, and sample outputs, demonstrating the project's implementation and user interaction. The project serves as a practical application for students in the Computer Science academic curriculum for the year 2020-21.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 34

ARALUMMOODU, TVPM.

PROJECT
IN

COMPUTER SCIENCE (083)


Academic Year 2020-21

ATM

NAME : …………………………………………………………………………………….

CLASS : …………………………………… ROLL.NO: ……………………………….

REG. NO: : ………………………………….. ACADEMIC YEAR: ……………………


ARALUMMOODU, TVPM.

BONAFIDE CERTIFICATE

This is to certify that this project report entitled


…………………...……………………………………is a bonafide
record of the project work done by ……………………………………
of class ….…… Reg.No …..….…… in the academic year 20… - 20…
The project has been submitted in partial fulfillment of AISSCE for
practical held at Sree Vivekananda Memorial Public School, Aralummoodu
on …………..

Date:…………………………… Teacher in Charge

Internal Examiner External Examiner

PRINCIPAL
ACKNOWLEDGEMENT

I solemnly take the opportunity to thank all the helping hands who
made me to complete this project. First of all I thank the Almighty for keeping me
hale and healthy in order to successfully complete my work.

I wish to express my sincere gratitude to Mr. Jayasankar Prasad,


Principal of Sree Vivekananda Memorial Public School, for permitting me to carry
out the project and for the facilities he has provided for the fulfillment of this
project work.

I am greatly indebted to Mrs. Sudha B V, Teacher in Computer Science


who gave me immense support and guidance throughout the completion of this
project.

Last but not the least, I express my heartiest thanks to my lovable parents
and friends for their prayers, suggestions and encouragement for the successful
completion of the project.

Sincerely,
CONTENTS

 INTRODUCTION

 HARDWARE & SOFTWARE REQUIREMENTS

 SOURCE CODE

 SAMPLE OUTPUT

 CONCLUSION

 BIBLIOGRAPHY
INTRODUCTION
Python is an interpreted, high-level, general-purpose programming
language. Created by Guido van Rossum and first released in 1991,
Python’s design philosophy emphasizes code readability with its
notable use of significant whitespace. Its language constructs and
object-oriented approach aim to help programmers write clear, logical
code for small and large scale objects.

This project is done using the python programming language. This


program is titled ATM. As the name suggests, this program is a simple
version of an Automated Teller Machine. The program can be used to
perform many day to day transactions like Cash withdrawal, Deposit
and money transfer. The Work interface is very simple and suits any
type of users. The program also uses Structured Query language
connectivity to store and retrieve user data.
Hardware & Software Requirements

RAM : 2 GB (Minimum)

4 GB (Recommended)

Operating System : 32 bit x86

64 bit x64 (Recommended)

Hard Disk : Minimum 250 MB Free Memory

Processor : Dual Core 2.80 GHz or Greater

Screen Resolution : 1366 x 768 (Optimal)

Graphics Card : Minimum 64 MB

Platform : Windows 7/8/10 with SP1

Python Version : Python 3.0 or Greater


SOURCE CODE
import sys

import mysql.connector

import time

import random

import json

import pickle

import matplotlib.pyplot as py

#------------------------------------------------------------------------------------

print("\n WELCOME TO THE A T M")

print(" ************************************")

print("\n Before using the ATM, User Database has to be Created")

input("\n Click ENTER to continue")

cardlist=[]

mydb=mysql.connector.connect(host="localhost",user="root",passwd="123456",database="ATM")

mycursor=mydb.cursor()

input("\n ATM database established! Click ENTER to continue")

mycursor.execute("create table User(Name varchar(20),Age int(2),AC_Number int(10) primary

key,Card_Number int(16),PIN int(4),Balance_Amt int(10),Acc_Type varchar(10))")

print("\n|----------------------------------------------------------------------------|")

n=int(input("\nEnter the number of User Records You want to add:"))


for i in range(n):

name=input("\nEnter the Name:")

age=int(input("Enter the age:"))

ac=int(input("Enter the Account number:"))

cn=int(input("Enter the Card number:"))

pn=int(input("Enter the PIN:"))

bal=int(input("Enter your Account Balance(INR):"))

typ=input("Enter the Account type(Current/Savings):")

qry=("insert into User values(%s,%s,%s,%s,%s,%s,%s)")

data=(name,age,ac,cn,pn,bal,typ)

mycursor.execute(qry,data)

mydb.commit()

cardlist.append(cn)

ballist=[bal] #For storing all the balance values for plotting balance monitor

localtime1=time.asctime(time.localtime(time.time()))

datelist=[localtime1]

input("\nData Succesfully Stored in Database. Click ENTER to Proceed")

print("\n|----------------------------------------------------------------------------|")

while True:

cn=int(input("\nEnter Your Card number to Initiate the ATM:"))

if cn not in cardlist:

sys.stderr.write("Card Not Found. Try Again\n")

continue
pin1=int(input("Enter the PIN number:"))

print("\n|--------------------------------------------------------------------------|")

#VARIABLES--------------------------------------------------------------------------

mycursor.execute("select Card_Number from User where Card_Number=%s"%(cn,))

crd=mycursor.fetchone()

card=crd[0]

mycursor.execute("select PIN from User where Card_Number=%s"%(cn,))

pn=mycursor.fetchone()

pin=pn[0]

mycursor.execute("select Name from User where Card_Number=%s"%(cn,))

nm=mycursor.fetchone()

name=nm[0]

mycursor.execute("select AC_Number from User where Card_Number=%s"%(cn,))

acn=mycursor.fetchone()

acc=acn[0]
mycursor.execute("select Balance_Amt from User where Card_Number=%s"%(cn,))

blm=mycursor.fetchone()

bal=blm[0]

mycursor.execute("select Acc_Type from User where Card_Number=%s"%(cn,))

act=mycursor.fetchone()

typ=act[0]

mycursor.execute("select Age from User where Card_Number=%s"%(cn,))

ag=mycursor.fetchone()

age=ag[0]

piewithdrawal=0

piedeposit=0

piefund=0

piepin=0
#ACCOUNT DETAILS------------------------------------------------------------------

if pin==pin1:

print("\n ACCOUNT DETAILS")

print(" ---------------")

print(" NAME :",name)

print(" AGE :",age)

print(" ACCOUNT NO. :",acc)

print(" CARD NUMBER :",card)

print(" BALANCE AMT :",bal,"INR")

print(" ACCOUNT TYPE :",typ)

else:

sys.stderr.write("Incorrect PIN. Start Over!\n")

continue

#FUNCTIONS---------------------------------------------------------------------------

def Cash_Withdrawal():

global bal

global piewithdrawal

num=int(input("Enter your 4 Digit PIN:"))

if num==pin:

print("\nYour Account Balance is:",bal,"INR")


print("\nAccount Type:",typ)

while True:

amt=int(input("\nEnter the Amount You want to Withdraw:"))

input("Click ENTER to continue")

if amt>bal:

sys.stderr.write("Insufficient Balance!\n")

continue

else:

bal=bal-amt

ballist.append(bal)

upd=("update User set Balance_Amt=%s where Card_Number=%s")

one=(bal,cn)

mycursor.execute(upd,one)

mydb.commit()

time.sleep(2)

print("\nTransaction Succesful. Updated Balance Amount:",bal,"INR")

accdict={"NAME":name,"AGE":age,"ACCOUNT NO.":acc,"CARNUMBER":card,

"BALANCE AMT":bal,"ACCOUNT TYPE":typ}

accdict["Amount Withdrawn"]=amt
localtime=time.asctime(time.localtime(time.time()))

datelist.append(localtime)

accdict["Date_And_Time"]=localtime

myfile=open(r"C:\Users\admin\Desktop\RECEIPT.txt","w")

myfile.writelines(json.dumps(accdict))

print("\nTransaction Receipt in RECEIPT file")

trans=open(r"C:\Users\admin\Desktop\Transaction_History.dat","ab")

dict={"Amount Withdrawn":amt,"Balance":bal,"Date_And_Time":localtime}

pickle.dump(dict,trans)

trans.close()

print("\n|-----------------------------------------------------------------|")

piewithdrawal+=1

break

else:

sys.stderr.write("Incorrect PIN\n")

def Cash_Deposit():

global bal

global piedeposit
num=int(input("Enter your 4 Digit PIN:"))

if num==pin:

print("\nYour Account Balance is:",bal,"INR")

print("\nAccount Type:",typ)

amt=int(input("\nEnter the Amount You Want to Deposit:"))

input("\nClick ENTER to continue")

input("\nInsert Your Money on the Slot and Press ENTER key")

bal=bal+amt

ballist.append(bal)

upd=("update User set Balance_Amt=%s where Card_Number=%s")

one=(bal,cn)

mycursor.execute(upd,one)

mydb.commit()

time.sleep(2)

print("\nTransaction Succesfull. Your Current Account Balance is:",bal,"INR")

accdict={"NAME":name,"AGE":age,"ACCOUNT NO.":acc,"CARD NUMBER":card,"BALANCE

AMT":bal,"ACCOUNT TYPE":typ}

accdict["Amount Deposited"]=amt

localtime=time.asctime(time.localtime(time.time()))

datelist.append(localtime)

accdict["Date_And_Time"]=localtime
myfile=open(r"C:\Users\admin\Desktop\RECEIPT.txt","w")

myfile.writelines(json.dumps(accdict))

print("\nTransaction Receipt in RECEIPT file")

trans=open(r"C:\Users\admin\Desktop\Transaction_History.dat","ab")

dict={"Amount Deposited":amt,"Balance":bal,"Date_And_Time":localtime}

pickle.dump(dict,trans)

trans.close()

print("\n|--------------------------------------------------------------------|")

piedeposit+=1

else:

sys.stderr.write("Incorrect PIN\n")

def Fund_Transfer():

global bal

global piefund

num=int(input("Enter your 4 Digit PIN:"))

if num==pin:

print("\nYour Account Balance is:",bal,"INR")

print("\nAccount Type:",typ)

ben=int(input("\nEnter the Bank Account Number of the Benificiary:"))

print("\nYour Daily Transaction Limit is 50,000 INR")


while True:

amt=int(input("\nEnter the Amount You want to Transfer:"))

if amt<bal and amt<50000:

input("\nClick ENTER to Confirm")

print("\nProcessing")

time.sleep(2)

bal=bal-amt

ballist.append(bal)

upd=("update User set Balance_Amt=%s where Card_Number=%s")

one=(bal,cn)

mycursor.execute(upd,one)

mydb.commit()

print("\nTransaction Succesfull. Your Current Account Balance is:",bal,"INR")

accdict={"NAME":name,"AGE":age,"ACCOUNT NO.":acc,"CARD NUMBER":card,

"BALANCE AMT":bal,"ACCOUNT TYPE":typ}

accdict["Amount Transferred"]=amt

accdict["Beneficiary AC Number"]=ben

localtime=time.asctime(time.localtime(time.time()))

datelist.append(localtime)

accdict["Date_And_Time"]=localtime
myfile=open(r"C:\Users\admin\Desktop\RECEIPT.txt","w")

myfile.writelines(json.dumps(accdict))

print("\nTransaction Receipt in RECEIPT file")

trans=open(r"C:\Users\admin\Desktop\Transaction_History.dat","ab")

dict={"Amount Transferred":amt,"Balance":bal,"Beneficiary AC Number":ben,

"Date_And_Time":localtime}

pickle.dump(dict,trans)

trans.close()

print("\n|---------------------------------------------------------------|")

piefund+=1

break

elif amt>bal:

sys.stderr.write("Insufficient Balance\n")

continue

elif amt>50000:

sys.stderr.write("Amount Exceeded Transaction limit\n")

continue

else:

sys.stderr.write("Incorrect PIN\n")
def Pin_Change():

global piepin

num=int(input("\nEnter your 4 Digit PIN:"))

if num==pin:

input("Click ENTER to proceed to change PIN")

pin2=int(input("\nEnter the Current PIN:"))

if pin2==num:

pin3=int(input("\nEnter the New PIN:"))

while True:

pin4=int(input("\nPlease Enter the New PIN to Confirm:"))

if pin3==pin4:

upd=("update User set PIN=%s where Card_Number=%s")

one=(pin3,cn)

mycursor.execute(upd,one)

mydb.commit()

print("PIN Changed Succesfully!")

localtime=time.asctime(time.localtime(time.time()))

act=open(r"C:\Users\admin\Desktop\Activity.dat","ab")

dict1={"Activity":"PIN Changed","Date_And_Time":localtime}

pickle.dump(dict1,act)

act.close()

print("\n|--------------------------------------------------------------|")
piepin+=1

break

else:

sys.stderr.write("Password Mismatch! Try Again.\n")

continue

else:

sys.stderr.write("Incorrect PIN Entered\n")

else:

sys.stderr.write("Incorrect PIN\n")

def Acc_Info():

print("\nSelect Your Desired Service")

print("---------------------------")

print("\n >> 1.Transaction History 2. Account Visualisation 3.Account Activity")

choose=int(input("\nEnter Your Choice:"))

if choose==1:

hist=open(r"C:\Users\admin\Desktop\Transaction_History.dat","rb")

while True:

try:

hist1=pickle.load(hist)

print(hist1)

except EOFError:

break
if choose==2:

print(">> 1. Activity Chart 2. Balance Monitor")

get=int(input("Enter the Choice:"))

if get==1:

info=[piewithdrawal,piedeposit,piefund,piepin]

data=["Withdrawals","Deposits","Fund Transfers","PIN Change"]

py.pie(info,labels=data,autopct="%2.2f%%")

py.title("No. of Transactions")

py.show()

elif get==2:

py.plot(ballist,datelist,"g",linestyle="dotted",marker="d")

py.ylabel("Date and Time")

py.xlabel("Balance(INR)")

py.title("Balance Monitor")

py.show()

if choose==3:

try:

hist=open(r"C:\Users\admin\Desktop\Activity.dat","rb")

while True:

try:

hist1=pickle.load(hist)

print(hist1)

except EOFError:
break

except FileNotFoundError:

print("PIN not changed yet!")

#MAIN--------------------------------------------------------------------------------

print("\n|------------------------------------------------------------------------|")

print("\n S E R V I C E S")

print(" ===============")

print("\n 1.Cash Withdrawal 2.Cash Deposit")

print("\n 3.Fund Transfer 4.Change PIN")

print("\n 5.Account Information Inquiry 6.EXIT")

while True:

choice=int(input("\n<> Select the Serial Number of the Service you want or Hit 6 to EXIT:"))
if choice==1:

Cash_Withdrawal()

elif choice==2:

Cash_Deposit()

elif choice==3:

Fund_Transfer()

elif choice==4:

Pin_Change()

elif choice==5:

Acc_Info()

elif choice==6:

print("\n >>> Thank You For Using The ATM <<<")

break

else:

print("\n Invalid Input!")

break
SAMPLE OUTPUT
W E L C O M E T O T H E A T M

************************************

Before using the ATM, User Database has to be Created

Click ENTER to continue

ATM database established! Click ENTER to continue

|------------------------------------------------------------------|

Enter the number of User Records You want to add:3

Enter the Name:Hari

Enter the age:19

Enter the Account number:123456

Enter the Card number:23455

Enter the PIN:7654

Enter your Account Balance(INR):45000

Enter the Account type(Current/Savings):Current


Enter the Name:Sam

Enter the age:21

Enter the Account number:356272

Enter the Card number:32145

Enter the PIN:1234

Enter your Account Balance(INR):32456

Enter the Account type(Current/Savings):Savings

Enter the Name:Tom

Enter the age:20

Enter the Account number:75684

Enter the Card number:54673

Enter the PIN:1243

Enter your Account Balance(INR):76000

Enter the Account type(Current/Savings):Current

Data Succesfully Stored in Database. Click ENTER to Proceed

|-------------------------------------------------------------------|

Enter Your Card number to Initiate the ATM:23455

Enter the PIN number:7654

|-------------------------------------------------------------------|
ACCOUNT DETAILS

--------------

NAME : Hari

AGE : 19

ACCOUNT NO. : 123456

CARD NUMBER : 23455

BALANCE AMT : 45000 INR

ACCOUNT TYPE : Current

|-------------------------------------------------------------------|

S E R V I C E S

===============

1.Cash Withdrawal 2.Cash Deposit

3.Fund Transfer 4.Change PIN

5.Account Information Inquiry 6.EXIT

<> Select the Serial Number of the Service you want or Hit 6 to EXIT:1

Enter your 4 Digit PIN:7654

Your Account Balance is: 45000 INR

Account Type: Current

Enter the Amount You want to Withdraw:23800


Click ENTER to continue

Transaction Succesful. Updated Balance Amount: 21200 INR

Transaction Receipt in RECEIPT file

|------------------------------------------------------------------|

<> Select the Serial Number of the Service you want or Hit 6 to EXIT:2

Enter your 4 Digit PIN:7654

Your Account Balance is: 21200 INR

Account Type: Current

Enter the Amount You Want to Deposit:12000

Click ENTER to continue

Insert Your Money on the Slot and Press ENTER key

Transaction Succesfull. Your Current Account Balance is: 33200 INR

Transaction Receipt in RECEIPT file

|-------------------------------------------------------------------|

<> Select the Serial Number of the Service you want or Hit 6 to EXIT:3

Enter your 4 Digit PIN:7654

Your Account Balance is: 33200 INR

Account Type: Current

Enter the Bank Account Number of the Benificiary:876595

Your Daily Transaction Limit is 50,000 INR

Enter the Amount You want to Transfer:19800


Click ENTER to Confirm

Processing

Transaction Succesfull. Your Current Account Balance is: 13400 INR

Transaction Receipt in RECEIPT file

|-------------------------------------------------------------------|

<> Select the Serial Number of the Service you want or Hit 6 to EXIT:4

Enter your 4 Digit PIN:7654

Click ENTER to proceed to change PIN

Enter the Current PIN:7654

Enter the New PIN:1239

Please Enter the New PIN to Confirm:1239

PIN Changed Succesfully!

|-------------------------------------------------------------------|

<> Select the Serial Number of the Service you want or Hit 6 to EXIT:5

Select Your Desired Service

---------------------------

>> 1.Transaction History 2. Account Visualization

3.Account Activity
Enter Your Choice:1

{'Amount Withdrawn': 23800, 'Balance': 21200, 'Date_And_Time': 'Tue


Jan 12 18:59:07 2021'}

{'Amount Deposited': 12000, 'Balance': 33200, 'Date_And_Time': 'Tue


Jan 12 18:59:28 2021'}

{'Amount Transferred': 19800, 'Balance': 13400, 'Beneficiary AC


Number': 876595,

'Date_And_Time': 'Tue Jan 12 18:59:51 2021'}

<> Select the Serial Number of the Service you want or Hit 6 to EXIT:5

Select Your Desired Service

---------------------------

>> 1.Transaction History 2. Account Visualization


3.Account Activity

Enter Your Choice:2

>> 1. Activity Chart 2. Balance Monitor

Enter the Choice:1


<> Select the Serial Number of the Service you want or Hit 6 to EXIT:5

Select Your Desired Service

---------------------------

>> 1.Transaction History 2. Account Visualisation


3.Account Activity

Enter Your Choice:2

>> 1. Activity Chart 2. Balance Monitor

Enter the Choice:2


<> Select the Serial Number of the Service you want or Hit 6 to EXIT:5

Select Your Desired Service

---------------------------

>> 1.Transaction History 2. Account Visualisation


3.Account Activity

Enter Your Choice:3

{'Activity': 'PIN Changed', 'Date_And_Time': 'Tue Jan 1219:00:222021'}

<> Select the Serial Number of the Service you want or Hit 6 to EXIT:6

>>> Thank You For Using The ATM <<<

>>>
CONCLUSION
This program is an operative and efficient prototype of an
Automated Teller Machine. The program interface is simple and
suits any type of users. The program is a multi-utility device which
makes it versatile. It comes with every type of service that you
need in daily life like cash withdrawal, money transfer and account
visualization.

This prototype is programmed with python because of its


resourcefulness and flexibility. The program syntax is simple and
even a novel user can comprehend the program without difficulty.
In addition, the program offers simple formatting options and new
options can be added easily.
BIBLIOGRAPHY

Reference Text: Introduction to Python by Sumita Arora

www.google.com

www.stackexchange.com

www.wikipedia.com

www.w3schools.com

You might also like