E) Design a well-packaged MATLAB program, with user-friendly interface for the following game: [20 Marks] (i) Two players, A and B, play a game called Lotto by Two Players. The Lotto machine generates a random lotto number in the range 0-50. They tak
Show older comments
Design a well-packaged MATLAB program, with user-friendly interface for the following game: [20 Marks] (i) Two players, A and B, play a game called Lotto by Two Players. The Lotto machine generates a random lotto number in the range 0-50. They take turns choosing any number, positive or negative to build-up their total to the lotto number. Player A starts and may choose any number. After each move, the number chosen is added to a common running total. If the total exceeds the lotto number, a message indicating that the total is too high should be displayed, similarly the opposite if the number is too low. For example, a random lotto number of 45 is generated (hidden). A starts with 25(total=25), the script now displays that the total is too low. B then chooses 25(total=50). The script now says the total is too high. A chooses -10 (total 40), and so forth. Write a script file to simulate the game that allows each player to correct the total 20 times. If there is no matching total after 20 chances for each player, the player whose previous guess brought the total closest to the lotto number wins, otherwise they share the lotto winnings( if both equally closer).
3 Comments
Steven Lord
on 16 Oct 2019
This sounds like a homework assignment. If it is, show us the code you've written to try to solve the problem and ask a specific question about where you're having difficulty and we may be able to provide some guidance.
If you aren't sure where to start because you're not familiar with how to write MATLAB code, I suggest you start with the MATLAB Onramp tutorial (https://www.mathworks.com/support/learn-with-matlab-tutorials.html) to quickly learn the essentials of MATLAB.
MHLAWAKHE VATSHA
on 16 Oct 2019
John D'Errico
on 16 Oct 2019
What is the problem though? Where is your question?
Answers (1)
MHLAWAKHE VATSHA
on 17 Oct 2019
0 votes
Categories
Find more on Just for fun in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!