-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbank-just-main-second.cpp
95 lines (92 loc) · 1.97 KB
/
bank-just-main-second.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
#include <iostream>
using namespace std;
typedef struct {
int deleted=0;
int code;
string name;
int balance;
string address;
} customer;
customer customers[1000];
int count=0;
int main() {
while(true) {
cout << "Type what function you need to run:"<<endl;
cout << " 1. Add" << endl;
cout << " 2. Delete/Remove" << endl;
cout << " 3. Sum" << endl;
cout << " 4. List" << endl;
cout << " 5. Exit" << endl;
int i;
cin >> i;
switch(i) {
case 1: {
customers[count].deleted=0;
cout << "Type code: ";
cin >> customers[count].code;
cout << "Type name: (without space)";
cin >> customers[count].name;
cout << "Type balance: ";
cin >> customers[count].balance;
cout << "Type address: ";
cin >> customers[count].address;
count++;
}
break;
case 2: {
cout << "Type code of customer: ";
int code;
cin >> code;
for(int i=0;i<count;i++) {
if(customers[i].code == code) {
customers[i].deleted=1;
if(i == count-1) {
count--;
}
}
}
}
break;
case 3: {
int sum=0;
for(int i=0;i<count;i++) {
if(customers[i].deleted==1) {
continue;
}
sum+=customers[i].balance;
}
cout << "Sum of balance are "<< sum << "" << endl;
}
break;
case 4: {
for(int i=0;i<count;i++) {
if(customers[i].deleted==1) {
continue;
}
cout << " Name | Code | Address | Balance" << endl;
cout << " ";
cout << customers[i].name;
cout << " | ";
cout << customers[i].code;
cout << " | ";
cout << customers[i].address;
cout << " | ";
cout << customers[i].balance;
cout << endl;
cout << " =========================== " << endl;
}
}
break;
case 5: {
cout << "Exit" << endl;
return 0;
}
break;
default:
cout << "Error!" << endl;
break;
}
cout << endl;
}
return 0;
}