forked from ghostmkg/dsa-code
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBankingSystemUsingClasses.Cpp
More file actions
52 lines (44 loc) · 1.12 KB
/
BankingSystemUsingClasses.Cpp
File metadata and controls
52 lines (44 loc) · 1.12 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
#include <iostream>
#include <string>
using namespace std;
class BankAccount {
private:
string name;
int accountNumber;
double balance;
public:
void createAccount() {
cout << "Enter account holder name: ";
cin.ignore();
getline(cin, name);
cout << "Enter account number: ";
cin >> accountNumber;
balance = 0;
cout << "Account created successfully!\n";
}
void deposit(double amount) {
balance += amount;
cout << "Deposited: " << amount << endl;
}
void withdraw(double amount) {
if (amount > balance) {
cout << "Insufficient balance!" << endl;
} else {
balance -= amount;
cout << "Withdrawn: " << amount << endl;
}
}
void displayAccount() {
cout << "\nAccount Holder: " << name
<< "\nAccount Number: " << accountNumber
<< "\nBalance: " << balance << endl;
}
};
int main() {
BankAccount account;
account.createAccount();
account.deposit(5000);
account.withdraw(2000);
account.displayAccount();
return 0;
}