-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path3a.cpp
More file actions
52 lines (49 loc) · 1.35 KB
/
Copy path3a.cpp
File metadata and controls
52 lines (49 loc) · 1.35 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 Bank {
private:
int accNum;
string name;
double balance;
public:
Bank(int acno, string acname, double bal) {
accNum = acno;
name = acname;
balance = bal;
}
void deposit(double depo) {
if (depo > 0) {
balance += depo;
cout << "Total balance: " << balance << endl;
} else {
cout << "Deposit not allowed: Amount must be positive"
<< endl;
}
}
void withdraw(double amt) {
if (amt > 0 && amt <= balance) {
balance -= amt;
cout << "Withdrawal successful. Remaining balance: " <<
balance << endl;
} else if (amt > balance) {
cout << "Insufficient balance!" << endl;
} else {
cout << "Withdrawal amount must be positive" << endl;
}
}
void dispBalance() {
cout << "Acc num: " << accNum << endl;
cout << "Acc name: " << name << endl;
cout << "Acc balance: " << balance << endl;
}
};
int main() {
Bank ob1(2521025, "Kruthika", 25000.0);
ob1.dispBalance();
ob1.deposit(12000.0);
ob1.withdraw(5000.0);
ob1.withdraw(50000.0);
ob1.withdraw(-100);
return 0;
}