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

Create File Pointers

The document provides an algorithm for an ATM card machine program with the following functions: 1) Add an account with a pin code and initial balance, 2) Check an account balance with a pin code, 3) Change a pin code by writing new data to a temporary file and overwriting the original file, 4) Withdraw money by calculating a new balance and writing updated data to a temporary file to overwrite the original file, and 5) Exit the program. The algorithm uses file pointers and input/output operations to manage account data stored in a text file.

Uploaded by

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

Create File Pointers

The document provides an algorithm for an ATM card machine program with the following functions: 1) Add an account with a pin code and initial balance, 2) Check an account balance with a pin code, 3) Change a pin code by writing new data to a temporary file and overwriting the original file, 4) Withdraw money by calculating a new balance and writing updated data to a temporary file to overwrite the original file, and 5) Exit the program. The algorithm uses file pointers and input/output operations to manage account data stored in a text file.

Uploaded by

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

VEN JOE CANUMAY

ALGORITHM FOR ATM CARD MACHINE

*Declare Variables
*Create File Pointers
*Display Menu
*Receive value for menu
If option == 1
 ADD ACCOUNT
Open accounts.txt as append
Enter pin code you want to add
Enter the amount u have on your atm
Print on the accounts.txt
Close file

If option == 2
 CHECK BALANCE
Open accounts.txt as read
Enter pin code u want to show balance
Display the balance
Close file

If option == 3
 CHANGE PIN CODE
Open accounts.txt as read
Open temp.txt as write
Enter your old pin code
Scan the pin code in accounts.txt
If the pin code you entered is equal to the text file
Enter your new pin code
Print the pin code to the temp.txt
Close both files
Open accounts.txt as write, open temp.txt as read
Create a loop to scan the temp.txt
Scan the temp.txt and print all the text on the accounts.txt
Close both files

If option == 4
 WITHDRAW
Open accounts.txt as read
Open temp.txt as write
Enter pin code
Create a loop to find the pin code you entered is in accounts.txt
If entered correct pin code, proceed
Enter the amount to withdraw
Use operation to compute for withdraw (nb = cb - amt;)
Print the amount withdrawed, print your new balance
Print it to temp.txt
Close both files
Open accounts.txt as write
Open temp.txt as read
Create a loop to scan the temp.txt
Then Print all the text in the accounts.txt
Close both files

If option == 5
 EXIT
Exit the program

You might also like