Ask Question

A statistician would like to simulate rolling a single die until she has rolled the die a total of 100 times, or she rolls a six a total of 25 times, whichever comes first. Which boolean expression should she use for the to accomplish this? var rolls = 0; var sixes = 0; while () {var nextRoll = randomNumber (1, 6); if (nextRoll = = 6) {sixes = sixes + 1; }rolls = rolls + 1; }console. log (rolls); console. log (sixes); rolls > = 0 && sixes < 25rolls < 100 && sixes < 25rolls < 100 || sixes < 25rolls = 100 || sixes < = 25rolls

+1
Answers (1)
  1. 2 December, 19:28
    0
    The missing code is rolls < 100 && sixes < 25

    Explanation:

    From the question, the while loop is expected to terminate (stop rolling) with either rolls reaches 100 or sixes reaches 25. This means we expect if one of the two conditions

    rolls < 100 sixes < 25

    is not met, the while loop should stop and print the rolls and sixes.

    To achieve the aim, we use logical operator AND, &&, to join the two conditions in the while loop.

    With AND logical operator, if rolls reaches 100, the condition rolls < 100 will return false.

    So false && true - > false (While loop stop)

    If sixes reaches 25, the condition sixes < 25 will return false.

    So true && false - > false (While loop stop).
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “A statistician would like to simulate rolling a single die until she has rolled the die a total of 100 times, or she rolls a six a total of ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers