-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpr4.cpp
More file actions
168 lines (85 loc) · 1.82 KB
/
pr4.cpp
File metadata and controls
168 lines (85 loc) · 1.82 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;
class bank{
int acno;
char nm[100], acctype[100];
float bal;
public:
bank(int acc_no, char *name, char *acc_type, float balance){
acno=acc_no;
strcpy(nm, name);
strcpy(acctype, acc_type);
bal=balance;
}
void deposit();
void withdraw();
void display();
};
void bank::deposit(){
int damt1;
cout<<"\n Enter Deposit Amount = ";
cin>>damt1;
bal+=damt1;
}
void bank::withdraw(){
int wamt1;
cout<<"\n Enter Withdraw Amount = ";
cin>>wamt1;
if(wamt1>bal)
cout<<"\n Cannot Withdraw Amount";
bal-=wamt1;
}
void bank::display(){
cout<<"\n ----------------------";
cout<<"\n Accout No. : "<<acno;
cout<<"\n Name : "<<nm;
cout<<"\n Account Type : "<<acctype;
cout<<"\n Balance : "<<bal <<endl;
}
int main(){
int acc_no;
char name[100], acc_type[100];
float balance;
int ch=1;
cout<<"\n Enter Details: \n";
cout<<"-----------------------";
cout<<"\n Accout No. ";
cin>>acc_no;
cout<<"\n Name : ";
cin>>name;
cout<<"\n Account Type : ";
cin>>acc_type;
cout<<"\n Balance : ";
cin>>balance;
bank b1(acc_no, name, acc_type, balance);
do{
cout<<"\n\n############ MENU ################\n";
cout<<"\n1. Display the details of Account";
cout<<"\n2. Deposit an amount";
cout<<"\n3. Withdraw an amount";
cout<<"\n4. Show Balance";
cout<<"\n5. Exit";
cout<<"\n Enter your choice\n";
cin>>ch;
switch(ch){
case 1:
b1.display();
break;
case 2:
b1.deposit();
break;
case 3:
b1.withdraw();
break;
case 4:
b1.display();
break;
case 5:
cout<<"\nYou have been successfully exited!\n";
exit(0);
default:
cout<<"\n Enter the Valid Choice\n";
}
}while(ch!=5);