-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBanking_system_with_.cpp
More file actions
55 lines (51 loc) · 1.73 KB
/
Banking_system_with_.cpp
File metadata and controls
55 lines (51 loc) · 1.73 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
#include <iostream>
#include <string>
using namespace std;
int main() {
string ownerName, accountNumber;
double balance = 0.0, amount;
int choice;
cout << "Enter Account Holder's name: ";
getline(cin, ownerName);
cout << "Enter account number: ";
cin >> accountNumber;
cout << "Enter initial deposit amount: ";
cin >> balance;
do {
cout << "\nBanking Menu:\n";
cout << "1. Deposit\n2. Withdraw\n3. Check Balance\n4. Exit\n";
cout << "Enter your choice: ";
cin >> choice;
if (choice == 1) {
cout << "Enter deposit amount: ";
cin >> amount;
if (amount > 0) {
balance += amount;
cout << "Deposited: $" << amount << "\nNew Balance: $" << balance << endl;
} else {
cout << "Invalid deposit amount!" << endl;
}
}
else if (choice == 2) {
cout << "Enter withdrawal amount: ";
cin >> amount;
if (amount > 0 && amount <= balance) {
balance -= amount;
cout << "Withdrawn: $" << amount << "\nNew Balance: $" << balance << endl;
} else {
cout << "Invalid withdrawal amount or insufficient balance!" << endl;
}
}
else if (choice == 3) {
cout << "Account Holder: " << ownerName << "\nAccount Number: " << accountNumber
<< "\nCurrent Balance: $" << balance << endl;
}
else if (choice == 4) {
cout << "Exiting the banking system. Thank you!" << endl;
}
else {
cout << "Invalid choice! Please try again." << endl;
}
} while (choice != 4);
return 0;
}