Solved

generating a unique bank account

Posted on 2004-04-23
5
389 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

920 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

13 Experts available now in Live!

Get 1:1 Help Now