Solved

generating a unique bank account

Posted on 2004-04-23
5
388 Views
Last Modified: 2010-03-31
Hello, I am wondering if you can help me with my homework assignment.
I am trying to create a program that runs in bank teller machine.  From this teller if existing customer, you can withdraw, deposit and check balances,  If not, you can become a new customer.  When someone becomes a customer, an account number that identifies this particular cliet is generated.  How can I write a method to generate this account number?   The only information I am requesting from the new client is first name, lastname, telephone, and initial desposit.
Thank you.

 
0
Comment
Question by:j_cisek
  • 3
  • 2
5 Comments
 
LVL 92

Expert Comment

by:objects
ID: 10905434
Keep track of last ID generated and just increnment it each time.
0
 
LVL 7

Expert Comment

by:maheshexp
ID: 10905440
0
 
LVL 92

Accepted Solution

by:
objects earned 500 total points
ID: 10905442
public class IDGenerator
{
   int Next = 0;

   public IDGenerator(int lastid)
   {
      Next = lastid;
   }

   public int getNextID()
   {
      return ++Next;
   }
}
0
 
LVL 7

Expert Comment

by:maheshexp
ID: 10905454
simply....just put the numbe generated in the vector, during next number generation, check for it in the vector, or else,generate new number....but careful, u may not be sure that u will always generate unique number or it will take more time, since it can generate the same number if some 1000 numbers or more is in the vector and each time it makes a check and lot of resources will be wasted

 ============
S.M.W
0
 
LVL 92

Expert Comment

by:objects
ID: 10905569
:)
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now