import java.util.Random; import org.junit.Test; public class Demo1 {
public void getChance(int percentage){
Random random = new Random();
int i = random.nextInt(99);
if(i>=0&&i<percentage)
System.out.println("true");
else
System.out.println("false");
}
@Test
public void test(){
for(int i=0;i<100;i++){
this.getChance(76); //76%概率
}
}