Random number generator

 avatar
unknown
java
3 years ago
696 B
4
Indexable
package com.company;

import java.util.Random;

public class Main {
    public static void main(String arg[]) {
        Random dice = new Random();
        int number;
        for (int c = 1; c <= 6; c++) //c<=n where n is the total numbers that will be printed
        {
//          number = 1 + dice.nextInt(6)
//          dice.nextInt(6) -- 0 1 2 3 4 5
//                             +1
//                             1 2 3 4 5 6
            number = 1 + dice.nextInt(6);// where n is the maximum number of digits that will be used to generate each number
            System.out.println("you rolled " + number);
        }
    }

}





















Editor is loading...