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

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 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

Database Processing

Authors: David J. Auer David M. Kroenke

13th Edition

ISBN: B01366W6DS, 978-0133058352

More Books

Students also viewed these Databases questions