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;    
}

Recommended Answers

All 10 Replies

Your problem is that you're wring your program in a way such that you are not able to restrict your thought to a few things at a time. You need to organize your program, and accordingly, your thoughts, so that you can manage the complexity of the component that you are working with. Then you can test each component separately and experimentally figure out what are the sources of your problems.

how do i convert int to char...

int x[10];
char y;
???????

how do i convert int to char...

int x[10];
char y;
???????

Not sure what you are trying to do here, but if you have an integer from 0 - 9 (a single digit), you can convert it to a char by adding 48 (which is the ASCII value of 0). If the integer is negative or greater than 9, you can't store it in a char.

int x = 6;
char y = x + 48;  // y now stores '6'

You could write y = x + 48; more readably by writing y = x + '0'; .

i mean an array of int to an array of char

i mean an array of int to an array of char

Are all the integers in the array from 0 to 9?

Then you could loop through the array and convert the ints one by one using something like

char_array[index] = int_array[index] + '0';

In general, to convert any integer value to a std::string, you can use a stringstream:

stringstream sstream;
	string astring;
	int value = 213123;
	sstream << value;
	sstream >> astring;

why cant it read twice???

#include <iostream>
#include <fstream>
#include <string>
#include <ctime>
using namespace std;

int main(){
     fstream file;//create input stream
     
     file.open("temp.txt",ios::in|ios::out);
     if (file.fail( )){
         cout << "fail!" << endl;
         system("pause");
         exit (1);
     }
     
     string word;;
     while( file >> word)
         cout << word;
     
     system("pause");
     system("cls");
     
     file.seekg(ios::beg);
     while( file >> word)
         cout << word;
     
     system("pause");
     
     file.close();
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.