Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Random;
- import static java.lang.Math.*;
- public class TenDice {
- public static void main(String[] args) {
- Random generator = new Random();
- int numberOfTrials = Integer.parseInt(args[0]);
- int TOTAL_DICEROLLS = 10;
- int diceTotal = 0;
- for (int i = 0; i < numberOfTrials; i++) {
- rollDiceNTimes(TOTAL_DICEROLLS);
- }
- }
- public static int rollDiceNTimes(int n){
- int diceTotal = 0;
- for (int j = 0; j < TOTAL_DICEROLLS; j++) {
- diceTotal = diceTotal + (generator.nextInt(6)+1);
- }
- return diceTotal;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement