Question: 1. Open a blank script using the edit command and save it as AM10IM_Q1_XXXXxx.m where xxxxxx is your candidate number. (a) In your script, write

1. Open a blank script using the edit command and save it as AM10IM_Q1_XXXXxx.m where xxxxxx is your candidate number. (a) In your script, write a code which rolls a standard 6-sided die once such that the probability of each outcome is equal. (2 marks) (b) Add another section of code which continuously rolls the die and termi- nates the rolls when a 6 is rolled. Save the outcomes of the rolls (including the final 6) in a vector called rolls. (6 marks) (c) Display the vector rolls after a 6 is achieved with the message: You have won!. (2 marks) (d) Amend your code with a new variable called lastRoll (initialised with a suitable value) which stores the value of the previously rolled number. Then, add an if statement so that the code terminates the dice rolls and throws an error with the message "You have lost. You rolled two x's in a row. if the same number x is rolled twice in succession. Replace x with the number that was rolled twice. (10 marks) 79
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
