Question: TASK(PHP): Use a while-loop to simulate a dice roll (random number between 1-6). Stop the loop when a 6 is rolled. Task Description This is
TASK(PHP): Use a while-loop to simulate a dice roll (random number between 1-6). Stop the loop when a 6 is rolled.
Task Description This is a very simple task to help you understand how to use a while loop. Your task is to simulate rolling a standard dice until a 6 is reached. To do that, create a variable called $dice and first assign it -1. Then create a while loop that keeps looping until $dice is equal to 6. You need to think carefully about what is the appropriate condition for this loop. Inside the loop, assign a new random variable to $dice and print out the value (as shown above).
ini_set('display_errors', 1); # only need to call these functions error_reporting(E_ALL); # one time ?>
Lab 4
lab
Task 1: While loop
Simulate multiple dice rolls until a 6 is reached. Print out the results of each roll.
?>
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
