How to Delete an Account from Simple Banking System Prog

This is a working program: If you create an Account then try to create another Account, it prompts: Account Already Existing. After you close the Account, you should be able to create a new Account but instead it prompts Account Already Existing. Need assistance on the logic. Issue on the Open Account and Close Account. Thank you in advance.

compiler: Borlan 5.02

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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
#include <iostream.h>
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <dos.h>

void menu (void);
void open_accnt (void);
void deposit (void);
void withrawal (void);
void balance (void);
void close_accnt (void);
void exit (void);

struct new_accnt
{
char accnt_name [50];
char accnt_lname [50];
char type [50];
double cash;
};

int choice =0;
int open_a =0;
bool account=0;
double bal =0;
char close;
new_accnt w;

//------------------------------------------------------------------------------
void main (void)
{
   menu();
   clrscr();
  }
//----------------------------------------------------------------------------------------
void menu (void)
{
	clrscr();
	cout << "\n                W E L C O M E  T O  B A N K  O F  P A U T A N G \n\n\n";
	cout << "\n                          _________MAIN MENU__________\n";
   cout << "\n                          | [1] Open Account          |";
   cout << "\n                          | [2] Deposit Transaction   |";
   cout << "\n                          | [3] Withrawal Transaction |";
   cout << "\n                          | [4] Balance Inquiry       |";
   cout << "\n                          | [5] Close Account         |";
   cout << "\n                          | [6] Exit                  |";
   cout << "\n                          _____________________________";
	cout << "\n\n                          Please Enter your Choice: "; cin >> choice;

    if (choice == 1)
   {
		open_accnt();
      menu();
   }
   else if (choice == 2)
   {
		deposit();
      menu();
   }
   else if (choice == 3)
   {
		withrawal();
      menu();
   }
   else if (choice == 4)
   {
		balance();
      menu();
   }
   else if (choice == 5)
   {
		close_accnt();
      menu();
   }
   else if (choice == 6)
   {
   	exit();
   }
   else
   {
   clrscr;
   cout << "\n\n\n\n\n\n\t\t---> Please Enter Choice fron 1 to 6 Only <---";
	cout << "\n\n\n\n\n\n\t\t     Please Press Any Key To Contiue.....";
   getch();
   menu();
   }
   getch();
}
//------------------------------------------------------------------------------------------------------
void open_accnt (void)
{
   clrscr();
   if (open_a == 1)
   {
   	cout << "\n\n\n\n\n\t\t Invalid! Account Already Existing!";
   }
   else
	{
   cout << "\n\t   *****---------- O P E N   A C C O U N T ----------*****";
   cout << endl;
   cout << "\n\n\tPlease Enter Your First Name: ";
   gets (w.accnt_name);
	cout << "\n\n\tPlease Enter Your Last Name: ";
   gets (w.accnt_lname);
   cout << "\n\n\tCurrent or Savings Account: ";
   gets (w.type);
   retry:
   cout << "\n\n\tPlease Enter Initial Deposit: ";
   cin >> w.cash;
   if (w.cash<200)
   	{
      	cout << "\n\n\tSorry, Minimum Deposit allowed is 200";
         getch();
         goto retry;
      }
   		cout << "\n\n\n\t\t\t\t Account Created!";
	   	open_a = 1;
   }
  	getch();
   account=1;
   bal = w.cash;
   menu();
}
//------------------------------------------------------------------------------------------------------
void deposit (void)
{
	clrscr();
   if(open_a == 0)
   {
		cout << "\n\n\n\n\n\t\t\t\tPlease Open An Account First!";
   }
   else
   {
   cout << "\n\t *****---------- D E P O S I T   T R A N S A C T I O N ----------*****";
   cout << " ";
   cout <<"\n\n\t\tAccount Type: "<< w.type;
	double deposit_accnt=0;
   cout << "\n\n\t\t  Please Enter Amount To Deposit: ";
	cin>> deposit_accnt;
   bal = bal + deposit_accnt;
	cout<<"\n\n\t\t\t  New Balance is = "<< bal;
   }
	getch();
   menu();
}
//------------------------------------------------------------------------------------------------------
void withrawal (void)
{
	clrscr();
   if(open_a == 0)
   {
		cout << "\n\n\n\n\n\t\t\t\tPlease Open An Account First!";
   }
   else
   {
   cout << "\n\t****------ W I T H R A W A L   T R A N S A C T I O N -----****";
   cout << " ";
   cout << "\n\n\t\tAccount Type: "<< w.type;
   double withraw=0;
   cout << "\n\n\t\tPlease Enter Amount To Take Out: ";
   cin >> withraw;
  	cout<<"\n\n\t         Transaction Successful!";
   bal = bal - withraw;
   }
	getch();
   menu();
}
//---------------------------------------------------------------------
void balance (void)
{
	clrscr();
   if(open_a == 0)
   {
		cout << "\n\n\n\n\n\t\t\t\tPlease Open An Account First!";
   }
   else
   {
   cout << "\n\t       *****---------- B A L A N C E   I N Q U I R Y ----------*****";
	cout << " ";
   cout << "\n\n\n\t\t\t\tName: " << w.accnt_name;
   cout << "\n\n\n\t\t\t\tYour Account: " << w.type;
	cout << "\n\n\n\t\t\t\tYour Balance Is: "<< bal;
   }
   getch();
   menu();
}
//-----------------------------------------------------------------------
void close_accnt (void)
{
	clrscr();
   if(open_a == 0)
   {
		cout << "\n\n\n\n\n\t\t\t\tPlease Open An Account First!";
   }
   else
   {
   cout << "\n\t       *****---------- C L O S I N G   A C C O U N T ----------*****";
   cout << "\n\n\tYour Account Name:"<< w.accnt_name<<" "<<w.accnt_lname;
   cout << "\n\n\tAccount Type: "<< w.type;
   retrys:
   cout << "\n\n\tDo You Want To Close Your Accont? [Y/N] ";
   cin >> close;
   	if (close == 'y' || close == 'Y')
   	{
   		account=0;
      	cout << "\n\n\t\t\tAccount Closed!";
      	getch();
      	menu();
   	}
   	else if (close == 'n' || close == 'N')
   	{
   		menu();
   	}
      else
      {
      	cout << "\n\n\tSorry Invalid Input";
         getch();
         goto retrys;
      }
	}
	getch();
   menu();
}
//-------------------------------------------------------------------------------------------
void exit (void)
{
   cout << "\n\n\n\n\n\t\t          Thank You and See You Soon....";
	sleep(2);
	exit(0);
}
Last edited on
You reset account to 0, but,

1
2
3
4
if (open_a == 1)
   {
   	cout << "\n\n\n\n\n\t\t Invalid! Account Already Existing!";
   }


nothing is done to open_a when the user chooses to close the account.
I thought about that too.
I finally got it. Thank You for the assistance Olysold
Topic archived. No new replies allowed.