We are going to make one program on the dice roller in which the number in the dice will be selected randomly.
We are going to make one program on the dice roller in which the number in the dice will be selected randomly.We are going to make one program on the dice roller in which the number in the dice will be selected randomly.
To make a program over this firstly we need to make a class DiceRoller in which we will have a doGet() method in which we will have our application logic. To make the dice working randomly use the random() method of the class java.lang.Math. To print the number on the browser call the method getWriter() of the response object which will return the PrintWriter object. Now by the object of the PrintWriter class print the values of the dice on the browser.
The code of the program is given below:
import java.io.*;
|
XML File for this program:
<?xml version="1.0" encoding="ISO-8859-1"?>
|
The output of the program is given below:
![]() |
Ads