serhatyucell

week7 course - arrays 2

Nov 3rd, 2016
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.41 KB | None | 0 0
  1. import java.util.Random;
  2.  
  3.  
  4. public class RolliDice {
  5.     public static void main(String[] args) {
  6.         Random r = new Random();
  7.         int[] frequency = new int[7];
  8.         for (int i = 0; i < 10; i++) {
  9.             int dice = r.nextInt(6)+1;
  10.             frequency[dice]++;
  11.         }
  12.         System.out.println("Face\tFrequency");
  13.         for (int i = 0; i < frequency.length; i++) {
  14.            
  15.             System.out.println(i + "\t" + frequency[i]);
  16.         }
  17.  
  18.        
  19.        
  20.  
  21.     }
  22.  
  23. }
Advertisement
Add Comment
Please, Sign In to add comment