Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use java to calculate the probability of each point for 6000 rolls of 6-sided dice

Shulou Source: shulou.com Published: 2022-06-03 15:12:56 09月30日 Update

This article mainly introduces how to use java to calculate the probability of 6000 rolls of 6-sided dice for each point. It has a certain reference value. Interested friends can refer to it. I hope you will gain a lot after reading this article. Let's take a look at it.

The probability of each point for 6000 rolls of 6-sided dice

Import java.util.Random;public class Statistics {final static int Maxsize = 6000; public static void main (String [] args) {/ / TODO Auto-generated method stub Random rand = new Random (); int temp [] = new int [Maxsize]; for (int I = 0; I < Maxsize; iTunes +) temp [I] = rand.nextInt (6) + 1; int aquifers 0, bread0, cations 0, dudes 0, eBay 0, fouls 0; for (int I = 0; I < temp.length; ionization +) {if (temp [I] = = 1) astats + Else if (temp [I] = = 2) breadcrumbs; else if (temp [I] = = 3) cymbals; else if (temp [I] = = 4) dudes; else if (temp [I] = = 5) ethereals; else if (temp [I] = = 6) fags + } System.out.println ("1 appears:" + a + "2 appears:" + b + "3 appears:" + c + "4 appears:" + d + "5 appears:" + e + "6 appears:" + f + "\ n"); float one = (float) a/Maxsize, two = (float) b/Maxsize, three = (float) c/Maxsize, four = (float) ddeband Maxsize; float five = (float) e/Maxsize, six = (float) f/Maxsize The probability of occurrence of System.out.println (1 + ") is" + one "; the probability of occurrence of System.out.println (2 +" is "+ two); the probability of occurrence of System.out.println (3 +" is "+ three); the probability of occurrence of System.out.println (4 +" is "+ four); the probability of occurrence of System.out.println (5 +" is "+ five); the probability of occurrence of System.out.println (6 +" is "+ six);}}

Results:

Thank you for reading this article carefully. I hope the article "how to use java to calculate the probability of rolling 6 dice 6000 times per point" is helpful to everyone. At the same time, I also hope you can support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Tags: Probability articles points dice value interest at the same time more friends knowledge results editing industry information information channels channels references learning help support Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft Linux MySQL Docker Huawei