Thursday, April 25, 2013

Generate Random Numbers Java service

// pipeline
IDataCursor pipelineCursor = pipeline.getCursor();
String    length = IDataUtil.getString( pipelineCursor, "length" );
int Length = Integer.parseInt(length);

//initialising the variables
long min =1,max =1,Number =1;
String randomNumber = null ;

//looping in order to obtain minimum and maximum Range.
for(int i=1;i min = min*10;
 max = min*9;
pipelineCursor.destroy();

//Calculating the Random Number and Storing it to a temporary Variable.
Number = (long) Math.floor(Math.random() * max) + min;

//converting Long into String Output.
randomNumber = Long.toString(Number);

// pipeline
IDataCursor pipelineCursor_1 = pipeline.getCursor();
IDataUtil.put( pipelineCursor_1, "randomNumber", randomNumber );
pipelineCursor_1.destroy();

No comments:

Post a Comment