-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtask2.cpp
More file actions
51 lines (41 loc) · 1.16 KB
/
Copy pathtask2.cpp
File metadata and controls
51 lines (41 loc) · 1.16 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
#include <iostream>
using namespace std;
class BankAccount {
private:
double balance;
int accountNumber;
public:
string holderName;
BankAccount(string name, int accNum, double initialBalance) {
holderName = name;
accountNumber = accNum;
balance = initialBalance;
}
void deposit(double amount) {
if (amount > 0) {
balance += amount;
cout << "Deposited: ₹" << amount << endl;
} else {
cout << "Invalid deposit amount." << endl;
}
}
void withdraw(double amount) {
if (amount <= balance && amount > 0) {
balance -= amount;
cout << "Withdrawn: ₹" << amount << endl;
} else {
cout << "Insufficient balance or invalid amount." << endl;
}
}
void checkBalance() {
cout << "Current Balance: ₹" << balance << endl;
}
};
int main() {
BankAccount acc1("Tejo Hasini", 1001, 5000.0);
cout << "Account Holder: " << acc1.holderName << endl;
acc1.deposit(1500);
acc1.withdraw(2000);
acc1.checkBalance();
return 0;
}