-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path3_3.cpp
More file actions
65 lines (50 loc) · 1.49 KB
/
3_3.cpp
File metadata and controls
65 lines (50 loc) · 1.49 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
#include <iostream>
using namespace std;
const int MAX_ACCOUNTS = 100;
class Account {
public:
int accountNumber;
string name;
float balance;
void create(int accNum, string accName, float initialBalance) {
accountNumber = accNum;
name = accName;
balance = initialBalance;
}
void show() {
cout << "Account Number: " << accountNumber << endl;
cout << "Name: " << name << endl;
cout << "Balance: " << balance << endl << endl;
}
bool transfer(Account &to, float amount) {
if (balance >= amount) {
balance -= amount;
to.balance += amount;
return true;
} else {
return false;
}
}
};
int main() {
Account accounts[MAX_ACCOUNTS];
int totalAccounts = 0;
accounts[0].create(101, "Pushti", 1000);
accounts[1].create(102, "khushi", 500);
totalAccounts = 2;
cout << "Total Accounts: " << totalAccounts << endl << endl;
cout << "Initial Account Info:\n";
accounts[0].show();
accounts[1].show();
cout << "Transferring 200 from pushti to khushi...\n";
if (accounts[0].transfer(accounts[1], 200)) {
cout << "Transfer successful.\n";
} else {
cout << "Transfer failed. Insufficient balance.\n";
}
cout << "\nUpdated Account Info:\n";
accounts[0].show();
accounts[1].show();
cout<<"24ce052_pushti kansara";
return 0;
}