-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathATM.cpp
More file actions
127 lines (125 loc) · 3.63 KB
/
ATM.cpp
File metadata and controls
127 lines (125 loc) · 3.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>
//Functions
void login();
void mainMenu();
void checkBalance(float balance);
float moneyDeposit(float balance);
float moneyWithdraw(float balance);
void menuExit();
void errorMessage();
//Main Code
int main() {
//Local Declarations
int option,pin;
float balance = 15000.00;
int choose;
bool again = true;
// insert code here...
while (pin != 1520)
{
printf("ENTER YOUR SECRET PIN NUMBER:");
scanf("%d", &pin);
if (pin != 1520)
printf("PLEASE ENTER VALID PASSWORD\n");
}
while (again) {
mainMenu();
printf("=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n");
printf("Your Selection:\t");
scanf("%d", &option);
switch (option) {
case 1:
system("CLS");
checkBalance(balance);
break;
case 2:
system("CLS");
balance = moneyDeposit(balance);
break;
case 3:
system("CLS");
balance = moneyWithdraw(balance);
break;
case 4:
system("CLS");
menuExit();
return 0;
default:
errorMessage();
break;
}
printf("=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n");
printf("Would you like to do another transaction:\n");
printf("< 1 > Yes\n");
printf("< 2 > No\n");
scanf("%d", &choose);
system("CLS");
if (choose == 2)
{
again = false;
menuExit();
}
}
return 0;
}//main code
//Functions
void mainMenu() {
printf("******************Hello!*******************\n");
printf("**********Welcome to ATM Banking***********\n\n");
printf("****Please choose one of the options below****\n\n");
printf("< 1 > Check Balance\n");
printf("< 2 > Deposit\n");
printf("< 3 > Withdraw\n");
printf("< 4 > Exit\n\n");
}//Main Menu
void checkBalance(float balance)
{
printf("You Choose to See your Balance\n");
printf("\n\n****Your Available Balance is: $%.2f\n\n", balance);
}//Check Balance
float moneyDeposit(float balance)
{
float deposit;
printf("You choose to Deposit a money\n");
printf("$$$$Your Balance is: $%.2f\n\n", balance);
printf("****Enter your amount to Deposit\n");
scanf("%f", &deposit);
balance += deposit;
printf("\n****Your New Balance is: $%.2f\n\n", balance);
return balance;
}//money deposit
float moneyWithdraw(float balance)
{
float withdraw;
bool back = true;
printf("You choose to Withdraw a money\n");
printf("$$$$Your Balance is: $%.2f\n\n", balance);
while (back) {
printf("Enter your amount to withdraw:\n");
scanf("%f", &withdraw);
if (withdraw < balance) {
back = false;
balance -= withdraw;
printf("\n$$$$Your withdrawing money is: $%.2f\n", withdraw);
printf("****Your New Balance is: $%.2f\n\n", balance);
}
else
{
printf("+++You don't have enough money+++\n");
printf("Please contact to your Bank Customer Services\n");
printf("****Your Balance is: $%.2f\n\n", balance);
}
}
return balance;
}
void menuExit()
{
printf("--------------Take your receipt!!!------------------\n");
printf("-----Thank you for using ATM Banking Machine!!!-----\n");
}
void errorMessage() {;
printf("+++!!!You selected invalid number!!!+++\n");
}