Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1.  
  2. public class ScrabbleBet {
  3. public double estimate(int trials, int games, int winsNeeded, int winChance)
  4. {
  5. int total = (int)Math.pow(2, games);
  6. double numWin = 0;
  7. double lose = (100 - winChance)/100.0;
  8. double loseC = 0;
  9.  
  10. for (int i = 0; i < winsNeeded; i++)
  11. {
  12. loseC += (Math.pow(winsNeeded/100.0, i) + Math.pow(lose, games - i));
  13. }
  14. System.out.println(loseC);
  15.  
  16. return 1 - Math.pow(loseC, trials);
  17.  
  18. }
  19.  
  20. public static void main(String[] args)
  21. {
  22. System.out.println(new ScrabbleBet().estimate(2, 2, 1, 50));
  23. }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement