-
Notifications
You must be signed in to change notification settings - Fork 0
/
(08.22.23) Lab
56 lines (48 loc) · 1.08 KB
/
(08.22.23) Lab
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
#include<iostream>
#include<string>
using namespace std;
class BankAccount{
private:
string name;
int accno;
double balance;
public:
void SetDetails( string n,int a,double b){
name = n;
accno = a;
balance = b ;}
void OutputDetails(){
cout<<"Account Holder: "<<name<<endl<<"Account Number: "<<accno<<endl<<"Current Balance: ₹"<<balance<<endl;
}
void withdraw(double x){
if (x<=balance){
balance=balance-x;
cout<<"Withdrawn ₹"<<x<<" from the account."<<endl;
}
else cout<<"Insufficient balance or invalid withdrawal amount."<<endl;
}
void deposit(double x){
balance=balance+x;
cout<<"Deposited ₹"<<x<<" into the account."<<endl;
}
};
int main(){
BankAccount ba ;
string name ;
cin>>name;
int accnum ;
cin>>accnum;
double bal;
cin>>bal;
ba.SetDetails(name,accnum, bal);
ba.OutputDetails();
double amn;
cin>>amn;
ba.deposit(amn);
cin>>amn;
ba.withdraw(amn);
cin>>amn;
ba.withdraw(amn);
ba.OutputDetails();
return 0;
}