-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathATM.cpp
More file actions
142 lines (131 loc) · 4.03 KB
/
ATM.cpp
File metadata and controls
142 lines (131 loc) · 4.03 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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#include<iostream>
using namespace std;
double password = 2005;
double balance = 0;
string accountHolderName = "ABID HASSAN";
string accountType = "Savings";
string accountNumber = "00012345";
int Balancecheck();
double depositpaisa(double);
double withdrawpaisa(double);
void changePin();
void viewAccountInfo();
int main()
{
double pin;
cout<< " Welcome To "<<endl;
cout<< " +------------------------+"<<endl;
cout<< " | |"<<endl;
cout<< " | Bank |"<<endl;
cout<< " | |"<<endl;
cout<< " +------------------------+"<<endl;
cout<< endl;
cout<<"Enter Your 4 Digit Pin Code : "<<endl;
cin>>pin;
if(pin == password)
{
double amount;
char ch;
do
{
cout<< " ATM Menu: " <<endl;
cout<< "+-----------------------+" <<endl;
cout<< "| Menu |" <<endl;
cout<< "+-----------------------+" <<endl;
cout<< "| 1. Check Balance |" <<endl;
cout<< "| 2. Deposit Money |" <<endl;
cout<< "| 3. Withdraw Money |" <<endl;
cout<< "| 4. Change PIN |" <<endl;
cout<< "| 5. Account Information|" <<endl;
cout<< "| 6. Exit |" <<endl;
cout<< "+-----------------------+" <<endl;
cout << "Enter your choice: ";
cin >> ch;
switch (ch)
{
case '1':
Balancecheck();
break;
case '2':
cout<<"Enter amount to deposit: $";
cin>>amount;
depositpaisa(amount);
break;
case '3':
cout<<"Enter amount to withdraw: $";
cin>>amount;
withdrawpaisa(amount);
break;
case '4':
changePin();
break;
case '5':
viewAccountInfo();
break;
case '6':
cout<<"Exiting program. Thank you!"<<endl;
break;
default:
cout<<"Invalid choice. Please try again."<<endl;
break;
}
} while (ch != '6');
}
else
{
cout<<"Invalid Pin Code .../a";
}
return 0;
}
int Balancecheck()
{
cout<<"--------------------------------"<<endl;
cout<<"Your Current Balance is $"<<balance<<endl;
cout<<"--------------------------------"<<endl;
return 0;
}
double depositpaisa(double a)
{
balance += a;
cout<<"--------------------------------"<<endl;
cout<<"Amount of $"<<a<<" Deposited Successfully"<<endl;
cout<<"--------------------------------"<<endl;
return balance;
}
double withdrawpaisa(double a)
{
if (balance >= a)
{
balance -= a;
cout<<"--------------------------------"<<endl;
cout<<"Withdrawal of $"<<a<<" Successful"<<endl;
cout<<"--------------------------------"<<endl;
}
else
{
cout<<"--------------------------------"<<endl;
cout<<"Insufficient balance."<<endl;
cout<<"--------------------------------"<<endl;
}
return balance;
}
void changePin()
{
double newPin;
cout<<"Enter new 4-digit PIN: ";
cin>>newPin;
password = newPin;
cout<<"--------------------------------"<<endl;
cout<<"PIN changed successfully."<<endl;
cout<<"--------------------------------"<<endl;
}
void viewAccountInfo()
{
cout<<"--------------------------------"<<endl;
cout<< "Account Information:"<<endl;
cout<< "--------------------------------"<<endl;
cout<< "Account Holder Name: "<<accountHolderName<<endl;
cout<< "Account Type : "<<accountType<<endl;
cout<< "Account Number : "<<accountNumber<<endl;
cout<< "--------------------------------"<<endl;
}