here is an example of how it should look like: Write a MATLAB program to simulate the
Fantastic news! We've Found the answer you've been seeking!
Question:
here is an example of how it should look like:
Transcribed Image Text:
Write a MATLAB program to simulate the Shut the Box game that can: 1. Use two (2) 6-sided dice to interactively play the Shut the Box game for one player. 2. Print a number strip from 1 through 12 in the command window. 3. Generate two (2) random integers between 1 and 6 to represent the face value of rolling two dice. 4. Print the two (2) dice values on screen. 5. Sum the dice value and print the sum on screen for the player. 6. Ask the player to decide and input the number(s) to cross out. The player can decide to cross out multiple numbers by inputting multiple numbers in hard brackets, for example [129]. 7. Print all the crossed out number(s) on screen. 8. Print all the open numbers on screen. 9. The game should keep rolling dice, printing the dice, summing the dice, printing the sum, asking the player to cross out number(s), printing all the crossed numbers, and printing all the open numbers on screen, until the player can no longer cross out any number to create a sum as same as the sum of the dice. 10. If the player cannot cross out any number, the player simply presses the Enter key without providing any number. 11. When the player presses the Enter key without any number, the game should end. 12. If the numbers above six are all closed, the game should automatically roll only one of the dice. 13. After the game ends, compute the player's score by summing all the open numbers together. 14. Print the score for the player in the command window. Write a MATLAB program to simulate the Shut the Box game that can: 1. Use two (2) 6-sided dice to interactively play the Shut the Box game for one player. 2. Print a number strip from 1 through 12 in the command window. 3. Generate two (2) random integers between 1 and 6 to represent the face value of rolling two dice. 4. Print the two (2) dice values on screen. 5. Sum the dice value and print the sum on screen for the player. 6. Ask the player to decide and input the number(s) to cross out. The player can decide to cross out multiple numbers by inputting multiple numbers in hard brackets, for example [129]. 7. Print all the crossed out number(s) on screen. 8. Print all the open numbers on screen. 9. The game should keep rolling dice, printing the dice, summing the dice, printing the sum, asking the player to cross out number(s), printing all the crossed numbers, and printing all the open numbers on screen, until the player can no longer cross out any number to create a sum as same as the sum of the dice. 10. If the player cannot cross out any number, the player simply presses the Enter key without providing any number. 11. When the player presses the Enter key without any number, the game should end. 12. If the numbers above six are all closed, the game should automatically roll only one of the dice. 13. After the game ends, compute the player's score by summing all the open numbers together. 14. Print the score for the player in the command window.
Expert Answer:
Answer rating: 100% (QA)
Please find the required MATLAB code below Note that to read Enter key from user input I have used getkey available on MATLAB file exchange The copy of the file has also been provided below MAIN SCRIP... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
Here is an example of a transaction just took place in a store where hi-fi equipment is sold. A customer purchased a stereo system that cost him $1,000 on the following credit plan. No down payment,...
-
Here is an example of a Smiley Face Questionnaire. Notice how the questions are constructed in a positive statement, and how the responses are structure so that responses can be categorized and...
-
Here is an example of the Battle of the Sexes game discussed in the text. Two people, let us call them Michelle and Roger, although they greatly enjoy each others company, have very different tastes...
-
A gaseous hydrocarbon (containing C and H atoms) in a container of volume 20.2 L at 350 K and 6.63 atm reacts with an excess of oxygen to form 205.1 g of CO2 and 168.0 g of H2 O. What is the...
-
Your company, Enzyme, Inc., manufactures biological and chemical agents that have potential military uses. You understand that Congress is considering the contentious issue of how to revamp the...
-
2 1. An ice-making machine operates on the ideal refrigeration vapor-compression cycle, using refrigerant-134a as the working fluid. The power input to the ice machine is to be determined. TA 3 600...
-
Each message in a digital communication system is classified as to whether it is received within the time specified by the system design. If three messages are classified, use a tree diagram to...
-
David Roberts began an upholstery cleaning business on August 1 and engaged in the following transactions during the month: Aug. 1 Began business by depositing $30,000 in a bank account in the name...
-
Prove the agreement of Work in Process Inventory with job cost sheets pertaining to unfinished work. Post each to the T-account in the following order: (1) beginning balance, (2) direct materials,...
-
1. a. How much did the materials cost per unit change between June and July? b. How much did the conversion cost per unit change between June and July? 2. Which is the optimal choice of material and...
-
It takes 38.65 mL of a 0.0895 M hydrochloric acid solution to reach the equivalence point in the reaction with 25.00 mL of barium hydroxide, 2HCl(aq) + Ba(OH)(aq) 2HO(l) + BaCl(aq) What is the molar...
-
Relative purchasing power parity focuses on ________________ while absolute purchasing power parity focuses on _________________. a. price levels; price changes. b. inflation; price changes. c. price...
-
You have been working as a Tax Consultant at a Tax Consulting Firm for the past several years and are well known for being an expert when it comes to complex dividend and Amas itsion tanactions , You...
-
If a Volkswagen Passat costs $52,000 in Baltimore and 32,500 in Frankfurt, what is the implied exchange rate between the U.S. dollar and the euro?
-
2. Which one is not the capital lease criteria? A. the lease transfers ownership B. the lease contains an option to purchase the property at a bargain price D. the lease term is 65% or more of the...
-
Suppose that you invest $100 today in U.S. T-bills and hold your investment for 50 years. Using the annual average return from 1927-2018, what is the future value of this investment after 50 years?
-
Rehman started a partnership with Mohan and Lew by contributing RM10, 000, RM12000 and RM12, 000 respectively. Lew will be the active partner and manage the partnership. They agreed to share the...
-
Design a circuit which negative the content of any register and store it in the same register.
-
Laertes has an endowment of $20 each period. He can borrow money at an interest rate of 200%, and he can lend money at a rate of 0%. (Note: If the interest rate is 0%, for every dollar that you save,...
-
Consider an industry with three firms. Suppose the firms have the following supply functions: S1(p) = p, S2(p) = p 5, and S3(p) = 2p respectively. On the graph below plot each of the three supply...
-
The number of bottles of chardonnay demanded per year is $1, 000, 000 60, 000P, where P is the price per bottle (in U.S. dollars). The number of bottles supplied is 40, 000P. (a) What is the...
-
Two high aspect ratio identical rectangular wings \(\left(\begin{array}{lll}2L & x & 2 b\end{array} ight)\) are separated with a distance \(h\). Establish an expression for the downwash in terms of...
-
The Newtonian impact theory is valid at high angles of attack. The wall inclination for a blunt body gradually decreases along the free stream direction. For such cases, when this angle is less than...
-
The ellipsoid given in Problem 2.3 is also undergoing a pulsative major axis change with the same period but with phase difference \(\phi\). Express the equation of surfaces. Problem 2.3 An oblate...
Study smarter with the SolutionInn App