• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Pl. suggest a logic

 
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
My java generates a code say 'Job 1'.
The databse has 5(dynamic no of) executives say'E1','E2','E3','E4','E5' etc.
So when 'Job 1' is generated by the system, it should be assigned to the 'E1'.
Similarly,
'Job 2' ---- 'E2'
'Job 3' ---- 'E3'
'Job 4' ---- 'E4'
'Job 5' ---- 'E5'
'Job 6' ---- 'E1'
and so on.
Could anyone please suggest an algorithm for this.
Thanks.
 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As I can understand from your question, the Executives are only 5 and jobs can be any number.
So if you are sure that all your job names will be as Job1,Job2,....Job25,... you can hard code this "Job" while creating a substring of that variable and get only the number.
As,

Now you can easily get the executive from the database I suppose.
This is the logic which came first to mind may be there is some other easy way.
Hope this will do the job for you
Regards
[ May 13, 2003: Message edited by: Abhilash Vasudevan ]
 
Boon Subra
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Abilash,
Any thanks.
But the 'Job 1' may be 'A1' or 'B30' or '.
C60'.
The above code is dynamic.
the executives are also dynamic.Today there are 5 Executives, it may increase.
Pl. suggest a table sturcture.
Thanks
 
Abhilash Vasudevan
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am not so sure that I have understood your scenario properly.
Still assuming that you will be generating job after job and these have to be distributed among executives in the database uniformly, i would suggest the following.
Create a table of executives where there are fields alloted_jobs and completed_jobs (number datatypes) other than name, id, etc.
Each time you come across a new job just check the least value of alloted_jobs-completed_jobs (the difference) for each executive and allot it to that person. By doing so you will be loading all your executives almost uniformly. Take care to increase the alloted_jobs field by 1 as soon as you allot a new job and to increase the completed_jobs by 1 when it is reported completed.
Also you can get the least alloted persons list in an alphabetical or id wise order so that you can take the first person from the select always,if there are more than one with the least allots.
This saves from making a logic to give the jobs one after other executives.
Regards
 
Stinging nettles are edible. But I really want to see you try to eat this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic