Question: Assume that you've been asked to write a C# application that allows the user to play a simple dice game. The game begins by allowing

Assume that you've been asked to write a C# application that allows the user to play a simple dice game. The game begins by allowing the user to pick a number between 2 and 12 (the possible sum of 2 dice). The computer will then roll 2 dice up to 3 times. If the number chosen by the user comes up, the user wins and the game ends. If the number does not come up within 3 tries, the computer wins.

For example, if the user selects 7 and then rolls a 1 and a 2 (totals 3 not 7) and then a 2 and a 5 (totals 7), the user wins. BUT if the user selects 7 and rolls 1 and 2, 2 and 3, and finally 3 and 6, the computer wins.

An algorithm in pseudocode is given below.

In repl.it or Visual Studio, translate the algorithm into syntactically correct C# code, using Main method.

Algorithm

display instructions get number create a random number generator declare 2 integer variables d1 and d2 rolls = 0 do d1 = random number between 1 and 6 d2 = random number between 1 and 6 increment rolls display rolls, d1 and d2 while rolls < 3 and d1 + d2 is not equal to number if number = d1 + d2 then display YOU win else display COMPUTER wins end if

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!