Question: Write In Perl programming. Exercise #1 Randomly assign a number to each of the five dice. To use rand, you need to specify the upper

 Write In Perl programming. Exercise #1 Randomly assign a number to
Write In Perl programming.

Exercise #1 Randomly assign a number to each of the five dice. To use rand, you need to specify the upper limit rand(5) will generate a number between zero and 5. Remember all random numbers have a lower limit of zero so you'll have to add 1 to the value. The rand function generates a float (number with decimal points) rather than an integer. You can use the int function to convert the float to an integer. There are other ways of doing this such as only outputting the rtions of the number to the left of the decimal point, but int is the easiest for now. the program roll five dice and display results between 1 and 6, as well as the sum of the dice. We will do this with a loop next Exercise #2 Write a program that throws six dice, generating random numbers between one and so. Display each number as it is thrown, and after six throws, show the sum. Use a for loop to throw the dice six times, using the same variable for each throw. Exercise #3 Modify the last program to display strings explaining that you are going to throw the five die generate five numbers, show them one at a time like this: The first dice was X. The second dice was Y and so on, and display the sum on a separate line. Exercise #4-Write a program that rolls six dice, all with values between 1 and 6, Add up the result of the die. If the total is greater than 20, display a message that the user wins the game. If the total is not greater than 20, they lose. Modify the program to determine if the total die roll is odd or even and display the result

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!