Coding For Money Exchange at ATM
Coding For Money Exchange at ATM
PROJECT 1
1
Contents
1. Introduction .................................................................................................................................... 3
2. Methodology ................................................................................................................................... 4
4. Conclusion .................................................................................................................................... 11
5. Appendices ................................................................................................................................... 12
2
1. Introduction
1.1 Problem description
Money exchange service is necessary for those who are always involved in travelling
between countries due to circumstances such as business trips, family vacation, overseas study or
job, etc. Thus, the reason why most of this service is available at the airports, shopping malls, banks,
train stations, and even international corporate companies. Despite the availability of this service,
there are times when the queuing line or time could not meet the demand of users.
One factor that leads to such a problem is the lack of amount of service operators for money
exchanges. This is further shown by the space rented is usually small which could only be occupied
by a small number of workers. The service shop is usually barred and only allows a small space for
queueing. The bar is installed to prevent any robbery and risks towards the workers. Besides that,
since the system is not fully automated, there are chances of human errors during the transactions.
Plus, the time needed for a transaction to complete depends on the efficiency of the workers. Another
common issue happening in Malaysia is the illegal practices by money exchange service providers.
Some of the illegal practices unsupervised money exchange service providers are Illegal Deposit
Taking, illegal operators, disclosing and selling customers information, etc .
1.2 Objective
The framework of this project is to develop a prototype program as the basis for ATM
implementation. The code will be developed by using C programming language and will consider
the basic user interface of an ATM, scenarios of logical flow, and customers’ prompt and inquiry.
This report outlines the project’s program from the beginning of the coding, algorithm and flow
charts to C language testing and debugging. This report also informs the potential improvements of
the program to further increase the quality of the codes for implementation in ATMs.
3
2. Methodology
2.1 Algorithm
Step 1: Start
Step 2: Declare variable main_input.
Step 3: Clear display screen.
Step 4: Display user interface with the following information.
WELCOME TO ATM EXCHANGE
MAIN MENU
1. WITHDRAWAL
2. CASH DEPOSIT
3. BALANCE ENQUIRY
4. MONEY EXCHANGE SERVICE
5. CANCEL
Step 5: Read variable main_input.
Step 6: Check for invalid prompt. While (main_input>5 or main_input <1)
Prompt user to re-enter selection.
Read variable main_input.
Step 7: If main_input == 1
Call sub-process void withdrawal()
Else if main_input == 2
Call sub-process void cash_deposit()
Else if main_input == 3
Call sub-process void balance_enquiry()
Else if main_input == 4
Call sub-process void money_exchange()
Else
Clear display screen.
Display prompt for user to take card.
Step 8: Stop
4
2.1.2 Money Exchange Sub-process
Step 1: Start
Step 2: Declare variables exchange_options, return_menu, exchange_amount, exchange_constant,
exchange_after.
Step 3: Clear display screen.
Step 4: Display prompt for user to select currency exchange as follows:
1. MYR to USD
2. USD to MYR
3. MYR to IDR
4. IDR to MYR
5. MYR to SGD
6. SGD to MYR
Step 5: Read variable exchange_options.
Step 6: Check for invalid prompt. While (exchange_options>6 or exchange_options<1)
Prompt user to re-enter selection.
Read variable exchange_options.
Step 7: Clear display screen.
Step 8: Display prompt for user to enter the amount of money for currency exchange.
Step 9: Read variable exchange_amount.
Step 10: Clear display screen.
Step 11: If exchange_options == 1
Set exchange_constant = 0.2119
Calculate exchange_after = exchange_amount*exchange_constant
Display the total money exchange and the currency.
Else if exchange_options == 2
Set exchange_constant = 4.71887
Calculate exchange_after = exchange_amount*exchange_constant
Display the total money exchange and the currency.
Else if exchange_options == 3
Set exchange_constant = 3462.75
Calculate exchange_after = exchange_amount*exchange_constant
Display the total money exchange and the currency.
5
Else if exchange_options == 4
Set exchange_constant = 0.0002887841
Calculate exchange_after = exchange_amount*exchange_constant
Display the total money exchange and the currency.
Else if exchange_options == 5
Set exchange_constant = 0.28675614
Calculate exchange_after = exchange_amount*exchange_constant
Display the total money exchange and the currency.
Else
Set exchange_constant = 3.48728
Calculate exchange_after = exchange_amount*exchange_constant
Display the total money exchange and the currency.
Step 12: Display prompt for user to return to the main menu.
Step 13: Read variable return_menu.
Step 14: Check for invalid prompt. While (return_menu != ‘0’)
Prompt user to re-enter selection.
Read variable return_menu.
Step 15: Clear display screen.
Step 16: Call function main().
Step 17: Stop
6
2.2 Flowchart
7
2.2.2 Money Exchange Sub-process
8
3. Results and Discussion
3.1 C programming testing
After the C programming for the money exchange service has been developed, the C
program is tested to check for any bugs or incorrect logical flows. The following data was used to
run the program and the results are recorded.
First, the option to exchange currency from Malaysian Ringgit (MYR) to US Dollar (USD) was
selected. The amount of MYR 1000 was entered as the input.
Figure 1: Money exchange output when RM 1000 was entered for MYR to USD exchange.
From Figure 1, the equivalent USD for RM 1000 is USD 211.90. This value is obtained from the
program calculation in which the input was multiplied by an exchange rate set in the program as
0.2119. Figure 2 shows the coding used to set the exchange rate, calculate the value and display
command after the calculation
Figure 2: The C coding to obtain the result in Figure 1.Another currency exchange option is
selected, MYR to IDR and, the value RM 1000 is tested as the input. The exchange rate set in the
9
program is 3462.75. The equivalent IDR calculated is Rupiah 3462750.00 as shown in Figure 3.
Figure 3: Money exchange output when RM 1000 was entered for MYR to IDR exchange.
Next test implemented is the option to return to the main menu. Figure 4 displays the output when
selecting other options beside ‘0’ in which will prompt the user to retry entering ‘0’.
Figure 4: The outputs when the user does not select '0' to return to the main menu.
10
3.2 Improving the program
Although the success in logical test, the program is still not efficient to be implemented in an ATM.
This is due to the nature of change of exchange rate of currency. The program should be able to capture
real-time exchange rate before calculating the currency exchange. This program is written in a way that the
exchange rate is assigned as a constant depending on the user selection. Besides that, the program is also
limited to exchange rate of three different countries only. An efficient exchange rate service should be able
to cover most countries available especially common international currency such as US dollars.
The program should also include a force cancel button in which the customer can cancel any in
progress process. This allows the user to directly get their card and leave if there’s a situation where the
user needs to leave immediately. This button is already available, but the program developed for this project
does not utilize the button.
4. Conclusion
The program developed for this project could potentially serve as the basis for a new concept
of implementing money exchange service in ATMs. From the results section, it is found that simple
money exchange calculations could be done, and a few set conditions were done to ensure the logical
flow of the program. Three different currencies were considered and more could be implemented by
improving the program. Including real-time data would make this concept more acceptable and
deliverable.
The combination of this service into ATMs will solve multiple issues identified with money
exchange branch. More customers will feel safer from error transactions and scams, and more
satisfied with the automated machines which can deliver the service accurately and precisely. Plus,
customer can exchange money without waiting for the branch to open.
11
5. Appendices
C-programming codes:
#include <stdio.h>
void withdrawal();
void cash_deposit();
void balance_enquiry();
void money_exchange();
main()
{
int main_input;
return 0;
12
}
}
void withdrawal()
{
int money_input[10] = {50, 100, 150, 200, 300, 500, 600, 800, 1000};
float manual_input;
int withdrawal_account_input, withdrawal_money_input;
void cash_deposit()
{
int account_number, depository_status, depository_proceed;
int random_cash = rand() % 1000; //Generate a random number for cash deposit
void balance_enquiry()
{
int account_type, balance_status, depository_proceed;
int random_balance = rand() % 999999;
//Transaction is ended
else
{
system("cls");
printf("THANK YOU FOR USING OUR SERVICE.");
printf("\n\nPLEASE TAKE COUR CARD.\n\n");
return 0;
}
}
void money_exchange()
{
int exchange_options;
char return_menu;
float exchange_amount, exchange_constant, exchange_after;
//Prompt user to enter the amount of money for the selected currency exchange
system("cls");
printf("Please enter the amount of money to exchange: ");
scanf("%f", &exchange_amount);
system("cls");
16
//For different options of currency exchange selected
if (exchange_options == 1)
{
//To exchange money from MYR to USD
exchange_constant = 0.2119;
exchange_after = exchange_amount*exchange_constant;
printf("Total money exchange:\n\n\t\t %.2f (MYR) = %.2f (USD).", exchange_amount,
exchange_after);
}
else if (exchange_options == 2)
{
//To exchange money from USD to MYR
exchange_constant = 4.71887;
exchange_after = exchange_amount*exchange_constant;
printf("Total money exchange:\n\n\t\t %.2f (USD) = %.2f (MYR).", exchange_amount,
exchange_after);
}
else if (exchange_options == 3)
{
//To exchange money from MYR to IDR
exchange_constant = 3462.75;
exchange_after = exchange_amount*exchange_constant;
printf("Total money exchange:\n\n\t\t %.2f (MYR) = %.2f (IDR).", exchange_amount,
exchange_after);
}
else if (exchange_options == 4)
{
//To exchange money from IDR to MYR
exchange_constant = 0.00028878741;
exchange_after = exchange_amount*exchange_constant;
printf("Total money exchange:\n\n\t\t %.2f (IDR) = %.2f (MYR).", exchange_amount,
exchange_after);
}
else if (exchange_options == 5)
{
//To exchange money from MYR to SGD
exchange_constant = 0.28675614;
exchange_after = exchange_amount*exchange_constant;
printf("Total money exchange:\n\n\t\t %.2f (MYR) = %.2f (SGD).", exchange_amount,
exchange_after);
}
else
{
//To exchange money from SGD to MYR
exchange_constant = 3.48728;
exchange_after = exchange_amount*exchange_constant;
printf("Total money exchange:\n\n\t\t %.2f (SGD) = %.2f (MYR).", exchange_amount,
exchange_after);
}
17
//Prompt user to re-select for invalid selections
while (return_menu != '0')
{
printf("INVALID PROMPT. PLEASE SELECT 0 TO RETURN TO THE MAIN MENU.\n\n");
scanf("%c", &return_menu);
}
18