-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathATMmachine.cpp
More file actions
172 lines (160 loc) · 4.36 KB
/
Copy pathATMmachine.cpp
File metadata and controls
172 lines (160 loc) · 4.36 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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
#include <conio.h>
#include <iostream>
#include <string>
using namespace std;
/*Mini project - ATM
-> Check Balance
-> Cash Withdraw
-> User Details
-> Update Mobile No.
*/
class atm
{
private:
long int account_no;
string name;
int PIN;
double balance;
string mobile_no;
public:
void setData(long int account_no_a,string name_a,int PIN_a,double balance_a,string mobile_no_a)
{
account_no=account_no_a;
name=name_a;
PIN=PIN_a;
balance=balance_a;
mobile_no=mobile_no_a;
}
long int getAccountno()
{
return account_no;
}
string getName()
{
return name;
}
int getPin()
{
return PIN;
}
double getbalance()
{
return balance;
}
string getMobileNo()
{
return mobile_no;
}
void setMobile(string mob_prev,string mob_new)
{
if(mob_prev==mobile_no)
{
mobile_no=mob_new;
cout<<endl<<"Sucessfully updated mobile no.";
getch();
}
else
{
cout<<"Sorry!!! Please enter valid mobile no:";
getch();
}
}
void checkBalance()
{
cout<<"Your Balance is :"<<balance;
getch();
}
void getDetails()
{
cout<<"*** User Datails are ***"<<endl;
cout<<"Your Account no is -> "<<account_no<<endl;
cout<<"Your name is -> "<<name<<endl;
cout<<"Your Mobile no is -> "<<mobile_no<<endl;
cout<<"Your Balance is -> "<<balance<<endl;
}
void cashWithdraw(int amount_a)
{
if(amount_a>0 && amount_a<balance)
{
cout<<endl<<"Please collect your Cash";
cout<<endl<<"Available Balance"<<balance;
getch();
}
else
{
cout<<endl<<"Invalid Input or Insufficient Funds";
getch();
}
}
};
int main()
{
int choice=0,enterPin;
long int enterAccountNo;
system("cls");
atm a;
a.setData(1234567,"Aman",8504,45000.67,"8544219391");
do
{
system("cls");
cout<<endl<<"***** Welcome to ATM *****";
cout<<endl<<"Enter your Account No:";
cin>>enterAccountNo;
cout<<endl<<"Enter Your Pin";
cin>>enterPin;
if((enterAccountNo==a.getAccountno()) && (enterPin==a.getPin()))
{
do
{
int amount =0;
string oldMobileNo,newMobileNo;
cout<<endl<<"*** WELCOME TO ATM ***";
cout<<endl<<"Select Option:";
cout<<endl<<"1. Check Balance";
cout<<endl<<"2. Cash Withdraw";
cout<<endl<<"3. Show user Details";
cout<<endl<<"4. Upadate Mobile No";
cout<<endl<<"5. Exit";
cin>>choice;
switch(choice)
{
case 1:
cout<<endl<<"Your Bank Balance is "<<a.getbalance();
getch();
break;
case 2:
cout<<endl<<"Enter the amount :";
cin>>amount;
a.cashWithdraw(amount);
case 3:
cout<<endl<<"*** USER DETAILS ARE ***";
cout<<endl<<"->Account No: "<<a.getAccountno();
cout<<endl<<"->Name: "<<a.getName();
cout<<endl<<"->Balance: "<<a.getbalance();
cout<<endl<<"->Mobile No:"<<a.getMobileNo();
getch();
break;
case 4:
cout<<endl<<"Enter Old Mobile No:";
cin>>oldMobileNo;
cout<<endl<<"Enter New Mobile No:";
cin>>newMobileNo;
a.setMobile(oldMobileNo,newMobileNo);
break;
case 5:
exit(0);
default:
cout<<endl<<"Enter valid Data !!!";
}
}
while (1);
}
else
{
cout<<endl<<"User Details are Invalid !!! ";
getch();
}
}
while(1);
return 0;
}