
Answer:
import java.util.Random;
import java.util.Scanner;
public class Dice {
Â
 public static void main(String[] args) {
  Â
   Scanner sc = new Scanner(System.in);
   System.out.print("how many times want to roll: ");
   int n = sc.nextInt();
  Â
   Random ran = new Random();
   int[] arr = new int[7];
   int i = 0;
   while(i < n) {
     int r = ran.nextInt(6)+1; //1-6
     arr[r]++;
     i++;
   }
  Â
   double[] frequency = new double[7];
   for(i=1; i<7; i++) {
     frequency[i] = arr[i]/(double)n;
   }
  Â
   System.out.println("Number\t\toccurrences\t\tfrequency");
   for(i=1; i<7; i++) {
     System.out.print(i+"\t\t"+arr[i]+"\t\t\t");
     System.out.println(String.format("%.5f", frequency[i]));
   }
 }
}
/*
Sample run:
how many times want to roll: 400
Number    occurrences    frequency
1 Â Â Â 69 Â Â Â Â Â 0.17250
2 Â Â Â 71 Â Â Â Â Â 0.17750
3 Â Â Â 72 Â Â Â Â Â 0.18000
4 Â Â Â 59 Â Â Â Â Â 0.14750
5 Â Â Â 62 Â Â Â Â Â 0.15500
6 Â Â Â 67 Â Â Â Â Â 0.16750
*/
Explanation: