Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database In Depth Relational Theory For Practitioners

Authors: C.J. Date

1st Edition

0596100124, 978-0596100124

More Books

Students also viewed these Databases questions

Question

=+ a. How does this change affect the incentives for working?

Answered: 1 week ago