Computer Science, asked by Anonymous, 1 year ago

what do you mean by probability ? two dices are thrown .find the probability that the sum of the two numbers in the two dices is 10 , given that the first dices shows 6​

Answers

Answered by matthewplaysytlive
1

Answer:

import java.util.Scanner;

import java.util.Random;

public class DiceProbability

{public static void main(String[] args)

   {

       Scanner in = new Scanner(System.in);

       Random generator = new Random();

       int[] a = new int[12];

       System.out.println("Please enter a number of dice rolls");

       int rolls = in.nextInt();  

 

       for(int start = 0; start < rolls; start++)

       {int random = generator.nextInt(12) + 1;

           for(int side1= 0; start < rolls;)

           {a[random]++;

           }

       }

 

       System.out.println("Number of rolls: " + rolls);

       System.out.println("Sum of dice: " + "              " + "Probability");

       System.out.println("1's        : " + "              " + (double)a[1]/(double)rolls * 100 + "%");

       System.out.println("2's        : " + "              " + (double)a[2]/(double)rolls * 100 + "%");

       System.out.println("3's        : " + "              " + (double)a[3]/(double)rolls * 100 + "%");

       System.out.println("4's        : " + "              " + (double)a[4]/(double)rolls * 100 + "%");

       System.out.println("5's        : " + "              " + (double)a[5]/(double)rolls * 100 + "%");

       System.out.println("6's        : " + "              " + (double)a[6]/(double)rolls * 100 + "%");

       System.out.println("7's        : " + "              " + (double)a[7]/(double)rolls * 100 + "%");

       System.out.println("8's        : " + "              " + (double)a[8]/(double)rolls * 100 + "%");

       System.out.println("9's        : " + "              " + (double)a[9]/(double)rolls * 100 + "%");

       System.out.println("10's       : " + "              " + (double)a[10]/(double)rolls * 100 + "%");

       System.out.println("11's       : " + "              " + (double)a[11]/(double)rolls * 100 + "%");

       System.out.println("12's       : " + "              " + (double)a[12]/(double)rolls * 100 + "%");

Explanation:

Similar questions