Friday, 17 November 2017

Java Program to Emulate N Dice Roller


Code:

import java.util.Random;
import java.util.Scanner;


public class Emulation_N_Dice 
{
    public static void main(String args[])
    {
        System.out.println("Enter the number of dice: ");
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Random rand = new Random();
        do 
        {
            System.out.println("The values on dice are: ");
            for(int i=0; i
                System.out.println(rand.nextInt(6)+1);

            System.out.println("Continue: true/false");
        } while (sc.nextBoolean() == true);
        sc.close();
    }
}

Output:

Enter the number of dice: 
6
The values on dice are: 
1 1 1 2 2 6
Continue: true/false
true
The values on dice are: 
6 5 2 5 5 1
Continue: true/false
false



More Java Programs:













100+ Best Home Decoration Ideas For Christmas Day 2019 To Make Home Beautiful

Best gifts for Christmas Day | Greeting cards for Christmas Day | Gift your children a new gift on Christmas day This Christmas d...