-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathatm.cpp
More file actions
52 lines (44 loc) · 1.35 KB
/
atm.cpp
File metadata and controls
52 lines (44 loc) · 1.35 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
#include<iostream>
using namespace std;
void UserMenu (){
cout << "***************MENU***************" << endl ;
cout <<"1. Balance" << endl ;
cout << "2. Deposit" << endl ;
cout << "3. Withdraw" << endl ;
cout << "4. Exit" << endl ;
cout << "******************************" << endl ;
}
int main(){
double balance = 1000;
double deposit;
double withdraw ;
int option ;
do{
UserMenu();
cout << "Option : ";
cin >> option ;
cin.clear(); //cin.clear(): Clears the error state that occurs when invalid input is entered.
cin.ignore(); //cin.ignore(): Skips the invalid input so the next cin can work correctly.
system ("cls");
switch(option){
case 1 : cout << "Balance : " << balance << "$" << endl;
break;
case 2 : cout << "Deposit : ";
cin >> deposit ;
balance += deposit ;
break;
case 3 : cout << "Withdraw ammount : ";
cin >> withdraw;
if(withdraw <= balance){
balance -= withdraw;
}
else{
cout << "Not Enough Money" << endl;
}
break;
default :
cout << "Not Valid" << endl;
}
}while(option != 4);
return 0;
}