Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In perl Exercise #1 Randomly assign a number to each of the five dice. To use rand, you need to specify the upper limit rand(5)

image text in transcribed In perl
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 d e 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

define the term outplacement

Answered: 1 week ago

Question

describe the services that an outplacement consultancy may provide.

Answered: 1 week ago