Bank management system using c++?

Hi everyone :) I've been given a project which asks to write a code in c++ language about bank management system. the result should be three options: depositing, withdrawing, and checking the balance. this should be done using a file to store the users name, account no. , and the balance and without using classes. i wrote a code which can do that but without using a file and only for one client . this is my code :



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
#include <iostream>
#include <string>

using namespace std;

struct account
{
string name; 
int CustAc;
double Balance; 
} per1;

void deposit (void);
void withdrawl (void);
void F_Balance (void);



main( )
{
int i;
char A;
int o;
per1.name = "sara";
per1.Balance = 3000;
per1.CustAc = 1011002;

cout << "Please enter your account number "<< endl;
L2: cin >> o ;

if (o == per1.CustAc){



cout << "\t\tWELCOME " << endl;

L1: cout<<"\tplease choose:\n\n \t1- Deposit. 2- Withdrawl. 3- Check your balance. : ";
cin>>i;
switch (i)
{

case(1): deposit();break;
case(2): withdrawl();break;
case(3): F_Balance();break;
default:
cout<<" wrong entery, please try again\n";
system("pause");
system("cls");
goto L1; 
}

}
else
{
cout << " please enter a valid account number "<< endl;
goto L2;
}

cout<<"Do you like to continue? [Y / N] ";
cin>>A;
if ((A=='Y') || (A=='y'))
{
system("cls");
goto L1;
}



cout<<"Thank you\n";
system("pause"); 
}

void deposit (void)
{
int in;
cout<< "please enter the value to deposit" << endl;
cin >> in;
cout << " your balance now is: " << per1.Balance + in << endl;
per1.Balance= per1.Balance+in;


}

void withdrawl (void)
{
int in;
cout<< "please enter the value to withdrawl" << endl;
cin >> in;
cout << " your balance now is: " << per1.Balance - in << endl;
per1.Balance= per1.Balance-in;

}

void F_Balance (void)
{
cout << " your balance is : " << per1.Balance << endl;

}



it is working so well but i dont know how to use a file in here, so if the user enters an account no. the code will search in the file and deal with that person's information. i think i should use arrays and i have tried soo many times! but it didnt work. I just need a simple explanation of what I need to do :)

Thanks.
Last edited on
Arrays? That could work. It depends on what you want. If you want the program to store the information even when the program is closed or the users computer is shut down then you should use a file.... Think of files as electronic storage =].
First off, are they supposed to be able to withdraw more than there account has? I would some logic to make sure that can't happen.
For the file reading, use getline to get how ever many lines you need. So say you store all the info for a customer on one line, you'll just get the line that begins with account number x and print it out somewhere. Or if you store each piece of information on a line under account number x, just getline for how ever many pieces of info are attached to an account
Topic archived. No new replies allowed.