Generating a random number (Throwing a dice)



Program for throwing a dice

import java.util.*;

public class Main
{
public static void main(String[] args)
{
Random rand=new Random();
Scanner input = new Scanner(System.in);
        System.out.println("Throw the dice ,press 0 to throw the dice ");
    int s=input.nextInt();

if(s==0)
{
int b=rand.nextInt(6)+1;//will generate a num b/w 1 and 6
System.out.println("The dice Showed "+b);
}


else
{
System.out.println("Retry");
}
}
}





posted by lol ik

Comments

Popular Posts