-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbanking.cpp
More file actions
102 lines (83 loc) · 2.21 KB
/
banking.cpp
File metadata and controls
102 lines (83 loc) · 2.21 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
#include <iostream>
double showBalance(double balance);
double deposit(double balance);
double withdraw(double balance);
double fixedDeposit(double balance);
int main()
{
double balance = 1500000.75;
int choice;
do {
std::cout << "*************ENTER INTO THE BANK**************\n";
std::cout << "1. Show Balance\n";
std::cout << "2. Deposit Money\n";
std::cout << "3. Withdraw Money\n";
std::cout << "4. Fixed Deposit\n";
std::cout << "5. Exit\n";
std::cout << "Enter your choice: ";
std::cin >> choice;
switch (choice)
{
case 1:
std::cout << "Current Balance: " << showBalance(balance) << std::endl;
break;
case 2:
balance = deposit(balance);
break;
case 3:
balance = withdraw(balance);
break;
case 4:
balance = fixedDeposit(balance);
break;
case 5:
std::cout << "Exiting...\n";
break;
default:
std::cout << "Wrong Choice\n";
break;
}
} while (choice >= 1 && choice < 5);
return 0;
}
double showBalance(double balance)
{
return balance;
}
double deposit(double balance)
{
double amount;
std::cout << "Enter deposit amount: ";
std::cin >> amount;
balance += amount;
std::cout << "Deposited: " << amount << "\n";
return balance;
}
double withdraw(double balance)
{
double amount;
std::cout << "Enter withdrawal amount: ";
std::cin >> amount;
if (amount > balance)
{
std::cout << "Insufficient balance!\n";
return balance;
}
balance -= amount;
std::cout << "Withdrawn: " << amount << "\n";
return balance;
}
double fixedDeposit(double balance)
{
double amount;
std::cout << "Enter amount for fixed deposit: ";
std::cin >> amount;
if (amount > balance)
{
std::cout << "Insufficient balance for fixed deposit!\n";
return balance;
}
balance -= amount;
std::cout << "Fixed deposit created for: " << amount << "\n";
return balance;
}