Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

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

2025-02-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report