Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.concurrent.ThreadLocalRandom;
- public class CoinFlip {
- public static void main(String args[]){
- int randomNumber;
- int oneCount = 0;
- int twoCount = 0;
- double total;
- double averageOne=0, averageTwo=0;
- for(int i=0; i<20; i++){
- randomNumber = ThreadLocalRandom.current().nextInt(1, 2 + 1);
- if(randomNumber == 1){
- oneCount++;
- }else{
- twoCount++;
- }
- System.out.print(oneCount);
- averageOne = (oneCount / (oneCount + twoCount)) * 100;
- averageTwo = (twoCount / (oneCount + twoCount)) * 100;
- System.out.println(averageOne);
- System.out.println(averageTwo);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement