-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathATM_Mini_Project.cpp
More file actions
157 lines (145 loc) · 4.39 KB
/
ATM_Mini_Project.cpp
File metadata and controls
157 lines (145 loc) · 4.39 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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
#include<iostream>
#include<conio.h>
#include<cstring>
using namespace std;
// Features of ATM Mini Project
// 1. User can Check the balance
// 2. User can withdraw cash
// 3. Users details
// 4. Update Mobile Phone Number
// Class for ATM
class ATM
{
private:
long int acc_num;
string name;
int pin;
double balance;
string mobile;
public:
void setData(long int acc_num, string name, int pin, double balance, string mobile){
this->acc_num = acc_num;
this->name = name;
this->pin = pin;
this->balance = balance;
this->mobile = mobile;
}
long int getAccNum(){
return this->acc_num;
}
string getName(){
return this->name;
}
int getPin(){
return this->pin;
}
double getBalance(){
return this->balance;
}
string getMobile(){
return this->mobile;
}
void checkBalance(){
cout << "Your Balance is: " << this->balance << endl;
_getch();
}
void withdrawCash(double amount){
if(amount > 0 && amount <= this->balance){
this->balance -= amount;
cout << "Please collect your cash" << endl;
cout << "Your Remaining Balance is: " << this->balance << endl;
_getch();
}
else{
cout << "Invalid or Insufficient Amount" << endl;
_getch();
}
}
void ViewDetails(){
cout << "Account Number: " << this->acc_num << endl;
cout << "Name: " << this->name << endl;
cout << "Balance: " << this->balance << endl;
cout << "Mobile Number: " << this->mobile << endl;
_getch();
}
void updateMobile(string old_mobile, string new_mobile){
if(old_mobile == this->mobile){
cout << "Enter New Mobile Number: ";
cin >> new_mobile;
this->mobile = new_mobile;
cout << "Mobile Number Updated Successfully" << endl;
_getch();
}
else{
cout << "Invalid Mobile Number" << endl;
_getch();
}
}
};
int main()
{
int choice, account_num;
int pin;
double amount;
string old_mob, new_mob;
ATM user1;
user1.setData(123456789, "Mubashar", 123, 10000, "03087031050");
do
{
system("cls");
cout << "**********Welcome to ATM**********" << endl;
cout<< "Enter Account Number: ";
cin >> account_num;
cout << "Enter Pin: ";
cin >> pin;
if(account_num == user1.getAccNum() && pin == user1.getPin()){
do
{
system("cls");
cout << "==========Welcome Back " << user1.getName()<< "==========" << endl;
cout << "1. Check Balance" << endl;
cout << "2. Withdraw Cash" << endl;
cout << "3. View Details" << endl;
cout << "4. Update Mobile Number" << endl;
cout << "5. Exit" << endl;
cout << "Enter your choice: ";
cin >> choice;
switch (choice)
{
case 1:
user1.checkBalance();
_getch();
break;
case 2:
cout << "Enter Amount: ";
cin >> amount;
user1.withdrawCash(amount);
_getch();
break;
case 3:
user1.ViewDetails();
_getch();
break;
case 4:
cout << "Enter Old Mobile Number: ";
cin >> old_mob;
user1.updateMobile(old_mob, new_mob);
_getch();
break;
case 5:
exit(0);
break;
default:
cout << "Invalid Choice" << endl;
_getch();
break;
}
} while (choice != 5);
}
else{
cout << "Invalid Account Number or Pin" << endl;
_getch();
}
} while (1);
return 0;
}