Info

This question is closed. Reopen it to edit or answer.

While loops mixed with switch statements?

1 view (last 30 days)
Tyler Silva
Tyler Silva on 24 Oct 2015
Closed: Walter Roberson on 24 Oct 2015
To start off I want to tell you what my code is supposed to do:
  • At the very beginning, ask the user how much money he/she has in total (balance) to bet during the course of the game.
  • • Add in code so the user cannot ever bet more money than he/she has. If the user attempts to bet more money than his/her balance, display the user’s balance and prompt them to enter a bet that doesn’t exceed their balance.
  • • Your script already displays to the user whether he/she won or lost and the amount won. Add in code to keep track of the user’s total amount of money (balance). Display the current balance to the user during each round of play.
  • • At the end of each round, the user should be asked if he/she wants to play again. Game play should only continue as long as the user wants to play again and the user still has money left.
  • • When the user runs out of money or the user indicates he/she no longer wants to play, the game should stop and the user’s final balance (which could be $0) should be displayed.
I will attach my script, and I would like someone to look at it please, and tell me what you think. Im a little confused on if the user selects yes that they want to keep playing, I dont know how to keep the game running. Thanks!

Answers (0)

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!