newbies

need help. this is the situation. i was asked to make a project of bank accounts.this is how it works. user was asked to enter a bank acct,name, deposits and age(this part done). i do not know how to programme or use what kind of function in such a way that after the user has entered its particulars, he or she can retrieve back his/her or partiulars by entering the bank acct numbers(displaying acct number, name age,deposits). any ideas?
Last edited on
Why not create an account class? This will make it very easy.
ok thanks.... there is another problem
void times()
{
time_t rawtime;
time(&rawtime);
cout<<""<<ctime(&rawtime);
}
when i call the function in outfile<< times(); an error msg appears:
1>c:\users\user\desktop\pbl\depositsnsavings\depositsnsavings\dns.cpp(11) : warning C4996: 'ctime': This function or variable may be unsafe. Consider using ctime_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> c:\program files\microsoft visual studio 9.0\vc\include\time.inl(88) : see declaration of 'ctime'
Is there any other functions or source codes that can show time and date????
if lets say a user has made an account and the programme has already outfile it. how can i make the programme that in such a way when the user has exited and when the same user enter his/her account number... he/she can retrieve his/her particulars???? sorry for asking too many questions.
Are you asking that if someone has made an account and they then want to see their details how would you do so?

Perhaps create an array of objects and arrays for each type of information you will hold.
can u give me an example??? i am quite confused with array.
i wrote something like this:
cout<<"Please Enter your ID:"<<endl;
cin>>x;
cin.ignore();
{
ifstream infile ("acct file.txt");
while(!infile.eof())
{
infile>>x;
cout<<x<<endl;
}
infile.close();
system("pause");
}
but doesnt seems to work. i dont know how to read from ifstream.
how can i make an array which can store five data??? example int, string, int,int and int? and when i call that array it will show just that??
when i call that array it will show just that??

Please clarify your problem (like in point form, to be more organised anyways).

To make an array of five ints on the stack you may write int myArray[5];.
To make an array of five ints on the heap you may write int* myArray = new int[5];.


Back to your first post. Did you think of creating an Account class?
Last edited on
i understand your post. but storing the five data... how am i supposed to call that array using the subject's account number???
the problem i am facing:
i am having trouble with array's:
what if user wants to change his money which is stored in the array?<-----how am i gonna do that?
Did you think of creating an Account class?<--yes. is it similar to arrays??

My current programme is currently single user. trying to make it into multi user.
Last edited on
Did you think of creating an Account class?<--yes. is it similar to arrays??

Not really, I think you took "array of accounts" as "accounts having arrays to store data", which are different things.

The Account class looks somthing like this:
1
2
3
4
5
6
7
8
9
10
11
12
13
class Account
{
   public:
     // blablabla

   private:
     // here you store the "particulars"
     char* userName;  // or std::string...
     int accNumber;  // I assume it's plain numbers (no zeros at the front), otherwise you can use a string
     int userAge;
     double accDeposit;  // a float would be "enough" :D
     // etc
};


Then perhaps in your main/driver function, you have an array of Account objects, then when a user enters the account number, it walks along the array and searches for a matching one...and so on.

In the future, or like when you make it multi-user, you want maybe a std::vector so it would be easier when a user want to create or delete an account. You may also want a Bank class or an interface for users to interact with the Account class...I dunno. Anyways, that's "out of scope" at the moment...
Last edited on
#include <iostream>
#include <iomanip>
#include <string>
#include <time.h>
#include <fstream>
using namespace std;
void times()
{
time_t rawtime;
time(&rawtime);
cout<<""<<ctime(&rawtime);
}

class ABC
{
protected:
int number,age;
float amount;
string name;
public:
void enternamenumber(string,int,float);


};

void ABC::checkamount(float *al)
{
amount=*al;
while(*al<100)
{
cout<<"You entered insufficient amount of money."<<endl;
cout<<"Please enter again."<<endl;
cout<<"Please enter the amount you wish to deposit: $";
cin>>*al;
}
return ;
}
void ABC::enternamenumber(string n,int num,float j)
{
name=n;
number=num;
amount=j;
}


int main ()
{
times();
int number;
int px;
int xx;

string y; // name
int a, x; //age n accnt number
float amnt;
ABC b[x];

ofstream outfile("c:\\mydata\\acct.txt");
cout<<"\nWelcome to ABC bank"<<endl;
cout<<"The minimun requirement is $100 to open a bank account."<<endl;
cout<<"Please enter your particulars"<<endl<<endl<<endl;
cout<<"1)Do you wish to make a new account?"<<endl;
cout<<"2)Do you wish to check your account?"<<endl;
cout<<"Please enter the number of your choice:\t";
cin>>xx;
if(xx=1)
{
cout<<"Please enter your account number u wish to make: ";
cin>>x;
fflush(stdin);
cout<<"Please enter your name: ";
getline(cin, y);
cout<<"Please enter your age: ";
cin>>a;
cout<<"Please enter the amount you wish to deposit: $";
cin>>amnt;
outfile<<x<<endl;
outfile<<y<<endl;
outfile<<amnt<<endl;
outfile.close();
cout<<endl;
cout<<"Do you want to go back menu?\n";
cout<<"1. Yes"<<endl;
cout<<"2 No"<<endl;
cin>>number;
if (number==1)
return main();
else
cout<<" Thank you for register"<<endl;
cout<<"Have A Nice Day"<<endl;


}
if(xx=2)
{
cout<<"Please Enter your ID:"<<endl;
cin>>x;
cin.ignore();


ifstream infile;
infile.open("c:\\mydata\\acct.txt"); //read the information
while(!infile.eof())
{
infile>>x;
cout<<x<<endl;
infile>>y;
cout<<y<<endl;
infile>>amnt;
cout<<amnt<<endl;
}
infile.close();
system("pause");

}
b.enternamenumber(y,x);

}
This is my file currently. as u can see i have already done my class. can u tell me how to mod my programme to multi account pls??? currently it is still single user.
Last edited on
Topic archived. No new replies allowed.