-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbanking_system.cpp
More file actions
80 lines (75 loc) · 1.71 KB
/
banking_system.cpp
File metadata and controls
80 lines (75 loc) · 1.71 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
#include <iostream>
using namespace std;
void showBalance(double balance);
double deposit();
double withdraw(double balance);
int main()
{
double balance = 200;
int choice = 0;
do
{
cout << "****************************************************\n";
cout << "**************available choices are *****************\n";
cout << "1.Show Balance \n";
cout << "2.deposit money \n";
cout << "3.Withdraw money\n";
cout << "4.Exit\n";
cout << "********************************\n";
cout << "Enter your choices: ";
cin >> choice;
switch (choice)
{
case 1:
showBalance(balance);
break;
case 2:
balance += deposit();
showBalance(balance);
break;
case 3:
balance -= withdraw(balance);
showBalance(balance);
break;
case 4:
cout << "***THANKS FOR VISITING***\n";
break;
default:
cout << "Invalid choice\n";
break;
}
} while (choice != 4);
return 0;
}
void showBalance(double balance)
{
cout << "\nYour balance is: $ " << balance << '\n';
}
double deposit()
{
double amount = 0;
cout << "Enter your amount to be Deposited: ";
cin >> amount;
if (amount > 0)
{
return amount;
}
else
{
cout << "Thats not a valid amount\n";
return 0;
}
}
double withdraw(double balance)
{
double amount = 0;
cout << "Enter the amount to be withdrawn: ";
cin >> amount;
if (amount < balance)
return amount;
else
{
cout << "Insufficiant Balance:\n";
return 0;
}
}