-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBankManagement.cpp
100 lines (100 loc) · 2.87 KB
/
BankManagement.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
#include<iostream>
using namespace std;
class XYZBank
{
private:
long int acc_no, payee_ac;
string name;
float balance, dep, withd, transf;
public:
void OpenAccount()
{
cout<<"***************Welcome to XYZ BANK!*****************\nEnter your Full Name: ";
getline(cin, name);
cout<<"\nEnter a 4-digit number of your choice: ";
cin>>acc_no;
cout<<"\nEnter the initial depositing amount (in INR): ";
cin>>balance;
}
void displayAccount()
{
cout<<"\nName: "<<name;
cout<<"\nAccount No.: 102796"<<acc_no;
cout<<"\nAccount Balance (INR): "<<balance;
}
void amountDeposit()
{
cout<<"\nEnter the amount you want to deposit (INR): ";
cin>>dep;
balance+=dep;
cout<<"\nSuccessfully deposited (INR) "<<dep<<" to your account";
cout<<"\nYour total balance now is (INR): "<<balance;
}
void amountWithdraw()
{
cout<<"\nEnter the amount you want to withdraw (INR): ";
cin>>withd;
//This will execute only when balance is sufficient.
if(withd<=balance)
{
balance-=withd;
cout<<"\nSuccessfully withdrawn (INR) "<<withd<<" from your account";
cout<<"\nYour total balance now is (INR): "<<balance;
}
else
cout<<"\nSorry! You have insufficient balance in your account!";
}
void amountTransfer()
{
string payee;
cout<<"\nEnter the name of the Payee: ";
cin>>payee;
cout<<"\nEnter the account number of Payee: ";
cin>>payee_ac;
cout<<"\nEnter the amount you want to transfer (INR): ";
cin>>transf;
//This too will execute if sufficient balance exists.
if(transf<=balance)
{
balance-=transf;
cout<<"\nSuccessfully transfered (INR) "<<transf<<" to "<<payee;
cout<<"\nYour current balance is (INR): "<<balance;
}
else
cout<<"\nSorry! You have insufficient balance in your account!";
}
};
int main()
{
XYZBank b;
b.OpenAccount();
int c;
cout<<"\nNow that you've made your account, choose what action you want to do!";
do
{
//Menu for the functions
cout<<"\n\nSelect an option - \n1 Display Account Details\n2 Deposit Amount\n3 Withdraw Amount\n4 Transfer Amount\n5 Exit\n";
cin>>c;
switch(c)
{
case 1:
b.displayAccount();
break;
case 2:
b.amountDeposit();
break;
case 3:
b.amountWithdraw();
break;
case 4:
b.amountTransfer();
break;
case 5:
cout<<"\nIt was nice helping you! Have a great day ahead!\n";
break;
default:
cout<<"\nInvalid input!";
}
}while(c!=5);
return 0;
}