Advertisement
JackHoughton00

Dice Rolls

May 18th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. package dicerolls;
  2. import java.util.Scanner;
  3. import java.util.Random;
  4.  
  5. public class DiceRolls {
  6.  
  7. public static void main(String[] args) {
  8. int[] outcomes = new int[18];
  9. Scanner input = new Scanner(System.in);
  10. int numRolls;
  11. Random rand = new Random();
  12. int outcome;
  13. System.out.print("How many rolls? ");
  14. numRolls = input.nextInt();
  15.  
  16. for (int roll = 0; roll < numRolls; roll++) {
  17. outcome = (rand.nextInt(6)+ 1 ) + (rand.nextInt(6)+ 1 ) + (rand.nextInt(6) + 1 );
  18. outcomes[outcome] +=1;
  19. }
  20. for (int i =3; i <=18; i++) {
  21. System.out.println(i + ": " + outcomes[i]);
  22. }
  23. }
  24.  
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement