Results 1 to 5 of 5
- 05-16-2012, 02:30 AM #1
Member
- Join Date
- Mar 2010
- Posts
- 16
- Rep Power
- 0
Call Different Task Based on their Percentage
Question:- The above Config File have some type of weighing to Different Tasks (execute Task1 X% of the time, execute Task2 Y% of the time and execute Task3 Z% of the time and etc etc. Total weighing should add up to 100%.Java Code:Task1, X% Task2, Y% Task3, Z% ---- TaskN, N% And X + Y + Z + . . . + N = 100%
Code that I wrote:- I wrote a program in which I am reading the files line by line and stored all the lines in the ArrayList of String, and then I generated some random number between 1 and 100. So for example there are three Tasks-
Java Code:Task1 75% Task2 15% Task3 10%
Get a random number between 1-100. If the number is 1-75 do Task1, 76-90 do Task2, 91-100 do Task3. But how I can expand this for any Config File having N Tasks with any percentage number. I am stuck on this part.
Java Code:private static Random r = new Random(); private final static int Low = 1; private final static int High = 100; String sCurrentLine; ArrayList<Integer> percentageCalls = new ArrayList<Integer>(); br = new BufferedReader(new FileReader("S:\\config.txt")); int R = r.nextInt(High-Low) + Low; ArrayList<List<String>> allLines = new ArrayList<List<String>>(); while ((sCurrentLine = br.readLine()) != null) { allLines.add(Arrays.asList(sCurrentLine.split("\\s+"))); Collections.shuffle(allLines); } for (List<String> s1 : allLines) { percentageCalls.add(Integer.parseInt(s1.get(0))); } Collections.sort(percentageCalls, Collections.reverseOrder());
-
Re: Call Different Task Based on their Percentage
cross-posted: Call Different Task Based on their Percentage
- 05-16-2012, 02:40 AM #3
Member
- Join Date
- Mar 2010
- Posts
- 16
- Rep Power
- 0
Re: Call Different Task Based on their Percentage
Hi Fubarable, Any suggestion will be appreciated on my question.
- 05-16-2012, 05:56 AM #4
Re: Call Different Task Based on their Percentage
Why do they call it rush hour when nothing moves? - Robin Williams
- 05-16-2012, 06:04 AM #5
Moderator
- Join Date
- Jul 2010
- Location
- California
- Posts
- 1,606
- Rep Power
- 5
Re: Call Different Task Based on their Percentage
I recommend being forthright up front with crossposting...think of it from our perspective - we do this unpaid, in our spare and valuable time...what a slap in the face it is to find we spent our time trying to answer a question that has been answered (or even discussed) elsewhere. Given this, you shouldn't be surprised when a cross post is found by someone other than the original poster and activity and comments on your post(s) (at least those productive to you) diminish to zero.Hi Fubarable, Any suggestion will be appreciated on my question.Last edited by doWhile; 05-16-2012 at 06:07 AM.
Similar Threads
-
Time Based View of Call logs.
By Raguram in forum AndroidReplies: 0Last Post: 04-08-2012, 03:46 AM -
Transfer file get percentage complete
By LG87 in forum NetworkingReplies: 5Last Post: 06-16-2011, 09:04 PM -
Load percentage of an image
By trishtren in forum Java 2DReplies: 0Last Post: 04-15-2011, 02:02 PM -
is there is any java based call center dialer?
By 435.mahesh in forum Java SoftwareReplies: 0Last Post: 03-06-2009, 06:20 AM -
Percentage/decimal points?
By Exhonour in forum New To JavaReplies: 6Last Post: 01-16-2009, 10:35 PM


2Likes
LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks