Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

While loops mixed with switch statements?

조회 수: 1 (최근 30일)
Tyler Silva
Tyler Silva 2015년 10월 24일
마감: Walter Roberson 2015년 10월 24일
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!

답변 (0개)

태그

Community Treasure Hunt

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

Start Hunting!

Translated by