Sukriti Sharma
BAN USERimport java.util.Random;
public class RandomTriplet {
/**
* @author sukriti
* @param args
*/
public static void main(String[] args) {
String processString="HelloworldSukritiSharma";
String randomSolution=getRandomTriplet(processString);
System.out.println(randomSolution);
}
public static String getRandomTriplet(String processString)
{
Random a= new Random();
int maxRange=processString.length()-2;
int minRange=1;
int number=0;
String output="a"; //null string doesn't get concat
for( int i=1;i<=3;i++)
{
if(minRange<=processString.length()-(3-i))
{
number=a.nextInt(maxRange-minRange+1)+minRange;
maxRange=maxRange+1;
}
System.out.print(processString.charAt(number-1)+" ");
output=output.concat(String.valueOf(processString.charAt(number-1)));
minRange=number+1;
System.out.println(number);
}
output=output.substring(1);// removing 'a' which is initialized
return output;
}
}
RepEshikaLopez, general assistant at MMSS
Dedicated and reliable general assistant with background in and strong knowledge of secretarial and administrative principles. Capable of providing direct ...
Why it this code voted as negative? is there any problem with that ?
- Sukriti Sharma July 16, 2014