-
Notifications
You must be signed in to change notification settings - Fork 0
/
q3trial.cpp
136 lines (110 loc) · 3.58 KB
/
q3trial.cpp
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
#include<iostream>
using namespace std;
class bank
{
char cust_name[30];
int acc_no;
char acc_type[20];
float balance;
public:
void details();
void deposit();
void withdraw();
void display();
};
void bank::details()
{
cout << "Enter your name ";
cin >> cust_name;
cout << "Enter type of account(s/c) ";
cin >> acc_type;
cout << "Enter amount of money want to deposit";
cin >> balance;
cout<<"Account created successfully" <<endl;
}
void bank::deposit()
{
float amount;
cout << "Enter amount to be deposited";
cin >> amount;
balance= balance+amount;
cout <<"Amount credited successfully" <<endl;
}
void bank::withdraw()
{
float amt;
cout << "Enter amount to be withdrawn " << endl;
cin >> amt;
if((balance-amt) >=500)
{
balance=balance-amt;
cout <<"Amount debited successfully" << endl;
}
else
{
cout << "Insufficient balance " << endl;
}
}
void bank::display()
{
cout <<"Name : " << cust_name <<endl;
cout <<"Account number: "<< acc_no <<endl;
cout <<"Account type : " << acc_type <<endl;
cout <<"Balance : " << balance << endl;
}
int main()
{
const int cust_num=100;
int option;
bank* customer=new bank[100];
int ch;
int i;
int acc_no;
for (int i = 0; i < cust_num; ++i)
{ do
{
cout<<"Customer" << i+1 <<endl;
cout <<"WELCOME" << endl;
cout <<"Enter appropraite number"<<endl;
cout <<"1:Add an account " << endl;
cout <<"2:Deposit amount" <<endl;
cout <<"3:Withdraw amount" <<endl;
cout <<"4:Account statement" <<endl;
cin >> ch;
if(ch==1)
{
customer[i].details();
cout <<"Account number: " << i <<endl;
}
else
{
cout <<"Enter account number: " <<endl;
cin >> acc_no;
if(acc_no>i)
{
cout<<"This account number does not exist" <<endl;
cout<<"Try again" <<endl;
}
else
{
switch(ch)
{
case 2:customer[acc_no].deposit();break;
case 3:customer[acc_no].withdraw();break;
case 4:customer[acc_no].display();break;
}
}
}
cout<<"Do you want to continue? " <<endl;
cout<<"1:Continue" <<endl;
cout<<"2:Next customer" <<endl;
cout<<"3:Exit" <<endl;
cin >>option;
}while(option==1);
if(option == 3)
{
break;
}
}
return 0;
}