Advertisement
Guest User

Untitled

a guest
Sep 20th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.59 KB | None | 0 0
  1. import java.util.Random;
  2. import static java.lang.Math.*;
  3.  
  4. public class TenDice {
  5.   public static void main(String[] args) {
  6.     Random generator = new Random();
  7.    
  8.     int numberOfTrials = Integer.parseInt(args[0]);
  9.     int TOTAL_DICEROLLS = 10;
  10.     int diceTotal = 0;
  11.    
  12.     for (int i = 0; i < numberOfTrials; i++) {
  13.       rollDiceNTimes(TOTAL_DICEROLLS);
  14.     }
  15.   }
  16.  
  17.   public static int rollDiceNTimes(int n){
  18.     int diceTotal = 0;
  19.     for (int j = 0; j < TOTAL_DICEROLLS; j++) {
  20.         diceTotal = diceTotal + (generator.nextInt(6)+1);    
  21.     }
  22.     return diceTotal;
  23.   }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement