Answer:
Follows are the program to this question:
public class Main//defining a class
{
public static void main(String[] bax)//main method
{
int d1,d2,r; //defining integer variables
d1 = (int)(Math.random()*6) + 1;//defining d1 variables that use random method to store a random value
d2 = (int)(Math.random()*6) + 1;//defining d2 variables that use random method to store a random value
r= d1 + d2;//defining r variable that adds d1 and d2 values
System.out.println("On the first time die will gives: " + d1);//print values with the message
System.out.println("On the second time die will gives: " + d2);//print values with the message
System.out.println("The total roll value is: " + r);//print values with the message
}
}
Output:
On the first time die will gives: 6
On the second time die will gives: 1
The total roll value is: 7
Explanation:
In this code three integer variable "d1,d2, and r" is declared, in which the "d1 and d2" variable is used, that uses the random method to hold a random value from 1 to 6 in its variable.
In the next step "r" variable is declared that calculates the addition of the "d1 and d2", and at the last, it uses the print method to print value with the message.