Solved

generating a unique bank account

Posted on 2004-04-23
5
393 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses

617 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