-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBankAccount.cpp
More file actions
84 lines (75 loc) · 1.78 KB
/
Copy pathBankAccount.cpp
File metadata and controls
84 lines (75 loc) · 1.78 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
#include<iostream>
#include <conio.h>
using namespace std;
class BankAccount{
private:
int AccNumber;
string AccHolderName;
int Balance;
public:
void setAccNumber(int accnum){
AccNumber = accnum;
}
int getAccNumber(){
return AccNumber;
}
void setAccHolderName(string accname){
AccHolderName = accname;
}
string getAccHolderName(){
return AccHolderName;
}
void setBalance(int bal){
Balance = bal;
}
int getBalance(){
return Balance;
}
void deposit(){
int amount;
cout<<"enter amount to deposit : "<<endl;
cin>>amount;
Balance = Balance + amount;
}
void withdraw(){
int amount;
cout<<"Enter the amount to be withdrawn : "<<endl;
cin>>amount;
if (amount < Balance && amount > 0){
Balance = Balance - amount;
}
else{
cout<<"not enough balance";
}
}
void display(){
cout<<"Account Details: "<<endl;
cout<<"Account Number: "<<AccNumber<<endl;
cout<<"Account Holder Name: "<<AccHolderName<<endl;
cout<<"Current Balance: "<<Balance<<endl;
}
BankAccount(int accnum,string accname,int bal){
AccNumber = accnum;
AccHolderName = accname;
Balance = bal;
}
};
int main(){
int num;
BankAccount acc1(21,"aisha",200);
cout<<"Select from following: "<<endl;
cout<<"1.deposit amount "<<endl;
cout<<"2.withdraw amount "<<endl;
cin>>num;
if(num==1){
acc1.deposit();
acc1.display();
}
else if(num==2){
acc1.withdraw();
acc1.display();
}
else{
cout<<"Invalid input";
}
}