-
Notifications
You must be signed in to change notification settings - Fork 0
/
Hospital Management System1.cpp
125 lines (107 loc) · 3.38 KB
/
Hospital Management System1.cpp
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
#include<iostream>
using namespace std;
class ATM {
private:
int balance;
int pinCode, success;
public:
ATM(int bal, int pin) {
balance = bal;
pinCode = pin;
}
int getbalance() {
return balance;
}
int withdraw(int amount, int pin) {
if (pin != pinCode) {
return false;
}
if (amount > balance) {
return false;
}
balance -= amount;
return true;
}
void deposit(int amount) {
balance += amount;
}
int transfer(int amount, ATM receiver, int pin) {
if (pin != pinCode) {
return false;
success = withdraw(amount, pin);
if (success) {
receiver.deposit(amount);
return true;
}
else {
return false;
}
}
}
};
int main() {
ATM atm(1000, 1234);
int choice, amount, success, pin;
char op;
do{
system("cls");
cout << "\t\t\t\t-------------------------------------------\n";
cout << "\t\t\t\t||=============== HBL ATM ===============||\n";
cout << "\t\t\t\t-------------------------------------------\n";
cout << "\n\n";
cout << "1. View Balance \n" << endl;
cout << "2. Cash Withdraw \n" << endl;
cout << "3. Cash Deposit \n" << endl;
cout << "4. Cash Transfer \n" << endl;
cout << "5. Exit.\n" << endl;
cout << "\n\tEnter Your Choice : ";
cin >> choice;
switch (choice)
{
case 1:
cout << "Your Balance is :" << atm.getbalance();
break;
case 2:
cout << "Your Available Balance is :" << atm.getbalance() << endl;
cout << "Enter the Amount to Withdraw :";
cin >> amount;
success = atm.withdraw(amount, 1234);
if (success) {
cout << "Withdraw Successful..." << endl;
}
else{
cout << "Insufficient balance..." << endl;
}
break;
case 3:
cout << "Enter amount to deposit :";
cin >> amount;
atm.deposit(amount);
cout << "Deposit Successful..." << endl;
break;
case 4:
cout << "Your Available Balance :" << atm.getbalance() << endl;
cout << "Enter the Amount to Transfer :";
cin >> amount;
cout << "Enter Pin Code :";
cin >> pin;
success = atm.transfer(amount, atm, pin);
if (success){
cout << "Transfer Successfully..." << endl;
}
else{
cout << "Invalid pin or Insufficient Balance" << endl;
}
break;
case 5:
cout << "Thanks for using ATM" << endl;
exit(1);
break;
default:
cout << "Invalid Choice" << endl;
}
cout << "\nDo You Want To Try Another Transaction [Yes / No] :";
cin >> op;
}
while (op == 'y' || op == 'Y');
}