Question
Java: While Loop For Loop Random Number Generator Programming Activity Description: This lab requires you to simulate the rolling of two dice. Two dice consisting
Java:
While Loop
For Loop
Random Number Generator
Programming Activity Description: This lab requires you to simulate the rolling of two dice. Two dice consisting of 6 sides are rolled. Write a program that simulates this. The user will be asked if he/she wishes to continue the roll of dice. If the answer is, Y or y, then your application will continue to roll the two dice. Each roll of the dice mustoccur6 times, each time the user agrees to continue (see sample output). Use a for loop in order to keep track of the number of times the dice are rolled. You can name your program RollDiceTimes.java See sample output below.
Sample Output:
H:\>java RollDiceTimes
Rolling the dice...1
Their values are:
2 6
Rolling the dice...2
Their values are:
2 2
Rolling the dice...3
Their values are:
3 6
Rolling the dice...4
Their values are:
6 3
Rolling the dice...5
Their values are:
6 4
Rolling the dice...6
Their values are:
6 2
Roll them again (y = yes)? y
Rolling the dice...1
Their values are:
4 4
Rolling the dice...2
Their values are:
3 3
Rolling the dice...3
Their values are:
3 2
Rolling the dice...4
Their values are:
1 4
Rolling the dice...5
Their values are:
5 1
Rolling the dice...6
Their values are:
3 6
Roll them again (y = yes)? n
H:\>
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started