-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path(23-08-23)Bank_Account_details_using_constructor
61 lines (54 loc) · 1.13 KB
/
(23-08-23)Bank_Account_details_using_constructor
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
#include<iostream>
using namespace std;
class BankAccount{
string name;
int acno;
double balance;
public:
//void accountdetails(string n,int a,int b){
//name=n;
//acno=a;
//balance=b;
//}
void deposit(double d){
balance=balance+d;
cout<<"Deposited ₹"<<d<<" into the account."<<endl;
}
void withdraw(double w){
if(w>balance){
cout<<"Insufficient balance or invalid withdrawal amount."<<endl;
}
else{
balance=balance-w;
cout<<"Withdrawn ₹"<<w<<" from the account."<<endl;
}
}
void display(){
cout<<"Account Holder: "<<name<<endl;
cout<<"Account Number: "<<acno<<endl;
cout<<"Current Balance: ₹"<<balance<<endl;
}
BankAccount(string n,int a,int b){
name=n;
acno=a;
balance=b;
cout<<"Bank Account created Successfully"<<endl;
}
};
int main(){
string name;
int acno;
double balance;
double deposit;
double withdraw1,withdraw2;
cin>>name>>acno>>balance;
BankAccount c(name,acno,balance);
//c.BankAccount("Amita",2345678,123457.98765);
c.display();
cin>>deposit;
c.deposit(deposit);
cin>>withdraw1>>withdraw2;
c.withdraw(withdraw1);
c.withdraw(withdraw2);
c.display();
}