Chance problems program
Generating Chance of getting 0 is 75% percent and 1 is 25% percent probability
- import java.util.Random;
- public class Chance {
- public static int getChance(){
- Random randomNumber = new Random();
- int randomGenerator = randomNumber.nextInt(100);
- System.out.println(randomGenerator);
- if(randomGenerator < 75)
- return 0;
- else
- return 1;
- }
- public static void main(String[] args) {
- for(int i=0;i<10;i++){
- System.out.println(Chance.getChance());
- }
- }
- }
Comments
Post a Comment