i'm working on a banking system.....m stuck here....i dont know how to do this:
1.Their account should already have an amount of money for further processing.
2.All users are able to perform transactions such as withdrawal, deposit and check balance
etc.
3.Each user will have a file or record to store all the registration and transaction information.
pls help me...
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
const int maxstring = 200;
typedef char stringtype[maxstring];
void userpassword(){
system("cls");
stringtype in_username,in_password;
ifstream in;//create input stream
cout << "PLEASE ENTER YOUR USERNAME: ";
cin >> in_username;
cout << "PLEASE ENTER YOUR PASSWORD: ";
cin >> in_password;
in.open(in_username,ios::in);//check username with file name
if (in.fail( )){
cout << "INCORRECT USERNAME OR PASSWORD!" << endl;
system("pause");
exit (1);
}
string word;
int i=0;
while( in >> word)
{
if(word == in_password)//check password
i++;
}
if(i==0){
cout << "INCORRECT USERNAME OR PASSWORD!" << endl;
system("pause");
exit (1);
}
system("pause");
}
void newuser(){
system ("cls");
srand ( time(NULL) );
ofstream out;//create output stream
//-------------------------------USERNAME------------------------------------
char a_to_z[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ/n" ;
stringtype username;
int rand_num=0;
for(int x=0;x<5;x++){
rand_num = rand()%26;
username[x] = a_to_z[rand_num];//generate username
}
out.open(username, ios::out);//create & open output file
//--------------------------------ACCOUNT NUMBER------------------------------
int acc_num[10];
for(int x=0;x<10;x++)
acc_num[x] = rand()%10; //generate account number
out << "ACCOUNT NUMBER : ";
for(int x=0;x<10;x++)
out << acc_num[x];
out << endl;
out << "USERNAME : " << username << endl;
//--------------------------------PASSWORD------------------------------------
int password[5];
for(int x=0;x<5;x++)
password[x] = rand()%10; //generate password
out << "PASSWORD : ";
for(int x=0;x<5;x++)
out << password[x];
out << endl;
//------------------------------ENTER NEWUSER DETAILS-------------------------
string type, id, cnumber, address, name;
double amount;
cout << "ENTER YOUR NAME: ";
cin >> name;
out << "USERNAME/NAME : " << name << endl;
cout << "ENTER IDENTITY CARD NUMBER: ";
cin >> id;
out << "IDENTITY CARD NUMBER : " << id << endl;
cout << "ENTER YOUR ACCOUNT TYPE(current/savings): ";
cin >> type;
out << "ACCOUNT TYPE : " << type << endl;
cout << "ENTER YOUR CONTACT NUMBER: ";
cin >> cnumber;
out << "CONTACT NUMBER : " << cnumber << endl;
cin.ignore();
cout << "ENTER YOUR ADDRESS: ";
getline(cin, address);
out << "ADDRESS : " << address << endl;
cout << "AMOUNT TO BE DEPOSITED: RM";
cin >> amount;
out << "AMOUNT DEPOSITED: RM" << amount;
system("cls");
//------------------------SHOW ACCOUNT NUMBER, PASSWORD & USERNAME------------
cout << "ACCOUNT NUMBER: ";
for(int x=0;x<10;x++)
cout << acc_num[x];//display account number
cout << endl;
cout << "USERNAME: " << username << endl;//display username
cout << "PASSWORD: ";
for(int x=0;x<5;x++)
cout << password[x];//display password
cout << endl;
system("pause");
out.close();//close output file
}
int main(){
newuser();
userpassword();
return 0;
}