Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

ATM Simulator in COBOL, Assignments of Computer Programming

This COBOL program simulates a simple ATM system with PIN registration, authentication (up to 3 attempts), and basic banking operations like checking balance, depositing, and withdrawing money. It ensures valid transactions and loops through the menu until the user chooses to exit. The program uses structured `PERFORM` blocks, `EVALUATE` for menu handling, and 88-level condition names for clarity. While functional and well-organized, it could be improved with input validation and additional features like PIN change or transaction history.

Typology: Assignments

2024/2025

Uploaded on 05/08/2025

aditi-samargade
aditi-samargade 🇮🇳

1 document

1 / 7

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Mainframe Course Project
ATM Simulator using COBOL Language
Code:
IDENTIFICATION DIVISION.
PROGRAM-ID. ATM-SIMULATION.
AUTHOR. SATYA.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-USER-PIN PIC 9(4).
01 WS-ACCOUNT-BALANCE PIC 9(6)V99 VALUE 0.
01 WS-INPUT-PIN PIC 9(4).
01 WS-PIN-ATTEMPTS PIC 9 VALUE 0.
01 WS-MAX-ATTEMPTS PIC 9 VALUE 3.
01 WS-TRANSACTION-AMT PIC 9(6)V99.
01 WS-CHOICE PIC 9.
01 WS-CONTINUE PIC X.
01 WS-PIN-VALID PIC 9 VALUE 0.
88 PIN-IS-VALID VALUE 1.
88 PIN-IS-INVALID VALUE 0.
01 WS-CONTINUE-SESSION PIC 9 VALUE 1.
88 CONTINUE-SESSION VALUE 1.
88 END-SESSION VALUE 0.
01 WS-ATTEMPTS-LEFT PIC 9.
pf3
pf4
pf5

Partial preview of the text

Download ATM Simulator in COBOL and more Assignments Computer Programming in PDF only on Docsity!

Mainframe Course Project

ATM Simulator using COBOL Language

Code:

IDENTIFICATION DIVISION.

PROGRAM-ID. ATM-SIMULATION.

AUTHOR. SATYA.

ENVIRONMENT DIVISION.

CONFIGURATION SECTION.

DATA DIVISION.

WORKING-STORAGE SECTION.

01 WS-USER-PIN PIC 9(4).

01 WS-ACCOUNT-BALANCE PIC 9(6)V99 VALUE 0.

01 WS-INPUT-PIN PIC 9(4).

01 WS-PIN-ATTEMPTS PIC 9 VALUE 0.

01 WS-MAX-ATTEMPTS PIC 9 VALUE 3.

01 WS-TRANSACTION-AMT PIC 9(6)V99.

01 WS-CHOICE PIC 9.

01 WS-CONTINUE PIC X.

01 WS-PIN-VALID PIC 9 VALUE 0.

88 PIN-IS-VALID VALUE 1.

88 PIN-IS-INVALID VALUE 0.

01 WS-CONTINUE-SESSION PIC 9 VALUE 1.

88 CONTINUE-SESSION VALUE 1.

88 END-SESSION VALUE 0.

01 WS-ATTEMPTS-LEFT PIC 9.

PROCEDURE DIVISION.

MAIN-PROCEDURE.

DISPLAY "============================".

DISPLAY " WELCOME TO COBOL ATM ".

DISPLAY "============================".

PERFORM REGISTER-USER

PERFORM VALIDATE-PIN

IF PIN-IS-VALID

PERFORM ATM-MENU UNTIL NOT CONTINUE-SESSION

END-IF

DISPLAY "Thank you for using COBOL ATM.". DISPLAY "Have a nice day!". STOP RUN. REGISTER-USER. DISPLAY "============================". DISPLAY " REGISTER ". DISPLAY "============================". DISPLAY "Please set your 4-digit PIN: " WITH NO ADVANCING ACCEPT WS-USER-PIN DISPLAY "Enter initial deposit amount: $" WITH NO ADVANCING ACCEPT WS-ACCOUNT-BALANCE IF WS-ACCOUNT-BALANCE < 0 DISPLAY "Invalid amount. Setting default balance to $1000.00" MOVE 1000.00 TO WS-ACCOUNT-BALANCE END-IF

DISPLAY "4. Exit". DISPLAY "============================". DISPLAY "Enter your choice (1-4): " WITH NO ADVANCING. ACCEPT WS-CHOICE. EVALUATE WS-CHOICE WHEN 1 PERFORM CHECK-BALANCE WHEN 2 PERFORM DEPOSIT WHEN 3 PERFORM WITHDRAW WHEN 4 MOVE 0 TO WS-CONTINUE-SESSION WHEN OTHER DISPLAY "Invalid option. Please try again." END-EVALUATE. IF CONTINUE-SESSION DISPLAY "Do you want to perform another transaction? (Y/N): " WITH NO ADVANCING ACCEPT WS-CONTINUE IF WS-CONTINUE = "N" OR WS-CONTINUE = "n" MOVE 0 TO WS-CONTINUE-SESSION END-IF END-IF. CHECK-BALANCE. DISPLAY "============================". DISPLAY " ACCOUNT BALANCE ". DISPLAY "============================".

DISPLAY "Your current balance is: $" WS-ACCOUNT-BALANCE. DISPLAY "============================". DEPOSIT. DISPLAY "============================". DISPLAY " DEPOSIT ". DISPLAY "============================". DISPLAY "Enter amount to deposit: $" WITH NO ADVANCING. ACCEPT WS-TRANSACTION-AMT. IF WS-TRANSACTION-AMT > 0 ADD WS-TRANSACTION-AMT TO WS-ACCOUNT-BALANCE DISPLAY "Deposit successful!" DISPLAY "New balance: $" WS-ACCOUNT-BALANCE ELSE DISPLAY "Invalid amount. Deposit must be greater than zero." END-IF. DISPLAY "============================". WITHDRAW. DISPLAY "============================". DISPLAY " WITHDRAWAL ". DISPLAY "============================". DISPLAY "Enter amount to withdraw: $" WITH NO ADVANCING. ACCEPT WS-TRANSACTION-AMT. IF WS-TRANSACTION-AMT <= 0 DISPLAY "Invalid amount. Withdrawal must be greater than zero." ELSE IF WS-TRANSACTION-AMT > WS-ACCOUNT-BALANCE DISPLAY "Insufficient funds!"