Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

* IN MATLAB DEFINE: Write a program that simulates the rolling of two D20 dice - randomly generating an integer between 1 and 20 for

* IN MATLAB

image text in transcribed

DEFINE: Write a program that simulates the rolling of two D20 dice - randomly generating an integer between 1 and 20 for each die. If the total (sum) of the dice is even, display a message stating that you rolled an even number. If the total of the dice is odd, check if the total of the dice is a prime number. If the number is prime, print a message stating that the total is both odd and prime. Otherwise, print a message stating the total of the dice is odd and not prime. MEASURE: - Sum - Total of the two numbers after rolling two D20's (20-sided dice). - Parity - Odd versus even - Prime - Number only divisible by 1 and itself ANALYZE: - How can you generate random integers between 1-20? - How do you determine if a number is odd or even? - How do you check if a number is prime? IMPROVE: Code your solution in MATLAB, making sure that your solution both runs and produces the desired results. Then, turn in a PDF of your code to the D2L Dropbox following the naming format: lastName_firstName_LogicConditionalsCode.pdf Note that you can simply copy and paste your code into a program like Microsoft Word and save the file as a PDF or use the publish command to easily generate a PDF of your code. You can not submit images of your code - I must be able to copy and paste your code to test it. Remember that there is a special folder named "Late Labs" for anyone who misses the deadline but still wishes to submit their lab. Note that this DropBox also has a date where it will lock, and any assignments submitted here will be subject to a 30 -point penalty. Hints: Even numbers are divisible by 2, meaning they have a remainder of 0 . There is a basic arithmetic operation that can do this for you! When determining if the number is prime, you can use the basic function isprime(), where you insert the total of the two dice rolls between the parenthesis

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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2019 Wurzburg Germany September 16 20 2019 Proceedings Part 2 Lnai 11907

Authors: Ulf Brefeld ,Elisa Fromont ,Andreas Hotho ,Arno Knobbe ,Marloes Maathuis ,Celine Robardet

1st Edition

3030461467, 978-3030461461

More Books

Students also viewed these Databases questions