Computer Science, asked by divijasachdeva018, 7 months ago

write a program to generate random number to roll a dice

Answers

Answered by TriviaTramp
0

Answer:

int myRand () // Generate a 4 digit pseudo-random integer.

{

static int next = 3251 ; // Anything you like here - but not.

// 0000, 0100, 2500, 3792, 7600,

// 0540, 2916, 5030 or 3009.

next = ((next * next) / 100 ) % 10000 ;

return next ;

}

Hope it helps .

Explanation:

Answered by SƬᏗᏒᏇᏗƦƦᎥᎧƦ
5

/ * Roll dice.java * /

/ * write a program to roll a dice * /

public class Rolldice

{

public static void main (string Argos[ ] )

{

int min = 1 , max = 6 ;

int range = max - min +1 ;

int num1 = (int) (range * Math.random() + min) ;

int num2 = ( int ) (range * Math.random() + min);

System.out.println( " First throw: ” + num1);

System.out.println("Second throw:"+num2);

}

}

Hope it helps pls flw

Similar questions