This Java project simulates rolling one or more dice with a configurable number of sides and trials. It calculates and displays statistical data, including the mean, variance, and standard deviation, along with a visual histogram representing the frequency distribution.
The project is structured as follows:
dice-simulation/
│
├── src/
│ ├── Dice.java
│ ├── DiceSimulation.java
│ ├── SimulationResult.java
│ ├── Statistics.java
│ ├── Main.java
│
└── README.md
- Customizable Dice Simulation: Set the number of sides on the dice, the number of rolls and the number of the dice.
- Statistical Analysis: Calculate and display mean, variance, and standard deviation.
- Histogram Output: Visual representation of frequency distribution using histograms.
- Object-Oriented Design: Modular code with separation of concerns.
- Builder Pattern: Simplifies the configuration and creation of simulations.
-
To modify the number of rolls, sides, and dice, edit the
Main
class inMain.java
:DiceSimulation simulation = new DiceSimulation.Builder() .setNumberOfRolls(60) // Set the number of dice rolls .setNumberOfSides(6) // Set the number of sides on each die .setNumberOfDice(3) // Set the number of dice to roll .build();
- Java 8 or later.
-
Clone the repository or download the source files.
-
Open the project folder in Visual Studio Code.
-
Compile the Java files:
javac src/*.java