-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1_1.cpp
More file actions
90 lines (80 loc) · 1.73 KB
/
1_1.cpp
File metadata and controls
90 lines (80 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include<iostream>
using namespace std;
class bankaccount {
private:
char name[20];
int accountno;
int balance; // No need to redeclare balance in methods
public:
void getdata();
void deposit();
void withdraw();
void display();
};
// Function to get user data
void bankaccount::getdata() {
cout << "Enter your name:\n";
cin >> name;
cout << "Enter your account number:\n";
cin >> accountno;
cout << "Enter your balance:\n";
cin >> balance;
}
// Function to deposit money
void bankaccount::deposit() {
int d;
cout << "\nEnter deposit value:\n";
cin >> d;
balance += d; // Update the class balance
cout << "\nYour new balance: " << balance;
}
// Function to withdraw money
void bankaccount::withdraw() {
int w;
cout << "\nEnter withdrawal amount:\n";
cin >> w;
if (w <= balance) {
cout << "\nYou have sufficient balance.";
balance -= w; // Deduct from class balance
cout << "\nYour new balance is: " << balance;
} else {
cout << "\nWithdraw amount exceeds balance.";
}
}
// Function to display account details
void bankaccount::display() {
cout << "\nName: " << name;
cout << "\nAccount number: " << accountno;
cout << "\nBalance: " << balance;
}
// Main function
int main() {
bankaccount b1;
cout << "Bank Account Details:\n";
b1.getdata();
b1.deposit();
b1.withdraw();
b1.display();
cout<<"\n24ce052_pushti";
return 0;
}
/*
#include <bits/stdc++.h>
#include<iostream>
using namespace std;
int main() {
int A,B,C;
float avg;
cin>>A>>B>>C;
avg=(A+B)/2;
if(avg>C)
{
cout<<"YES";
}
else
{
cout<<"NO";
}
return 0;
}
*/