Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

use 5.010; my $number; my $sum=0; for(my $i=0;$i <5;++$i) {$number=int rand(5) + 1; $sum=$sum +$number; print Dice number is . $number , ; } print

use 5.010;

my $number;

my $sum=0;

for(my $i=0;$i<5;++$i)

{$number=int rand(5) + 1;

$sum=$sum +$number;

print "Dice number is ". $number ," ";

}

print "The sum is ".$sum;

Question 1

Using the sample above modify the last program to display strings explaining that you are going to throw the five dice, generate five numbers, and 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 line.

Question 2

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

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

MongoDB Applied Design Patterns Practical Use Cases With The Leading NoSQL Database

Authors: Rick Copeland

1st Edition

1449340040, 978-1449340049

More Books

Students also viewed these Databases questions

Question

Find an LU factorization of the given matrix. 2 -1 4 0 4

Answered: 1 week ago